Package com.avoka.tm.http
Class PatchRequest
- java.lang.Object
-
- com.avoka.tm.http.HttpRequest
-
- com.avoka.tm.http.PatchRequest
-
public class PatchRequest extends HttpRequest
Provides a PATCH Request class for performing simple HTTP request operations. This class provides an easier and safer interface for the Apache HTTP Components library.
The default connection timeout is 10 seconds and socket read timeout is 60 seconds. Socket connections will also apply any JVM proxy settings automatically.
By default the maximum response read size is 16 MB. If the response is larger than this an IOException will be thrown. To increase the maximum read limit use the
HttpRequest.setReadLimit(int)
method.In RESTful services the PATCH method is used to update resources.
Examples
The example below performs PUT request and converts the response into a JSON document.
import com.avoka.tm.http.* import com.avoka.tm.util.* String message = '''{ "cutomerId":82881, "name":"John Doe", "email":"[email protected]", "age":42 }''' String username = svcDef.paramsMap.username String password = svcDef.paramsMap.password // execute PUT request and return a HttpResponse object HttpResponse response = new PatchRequest('https://service.mycorp.com/secure/rest/accounts/') .setMessage(message) .setBasicAuth(username, password) .execute() if (response.isStatusOK()) { // get JSON object from the response Path path = response.getPathContent() ... } else if (response.isStatusNotFound()) { // object not found ... } else { throw new RuntimeException(response.statusLine) }
- Since:
- 5.0.0
- See Also:
DeleteRequest
,PutRequest
,PostRequest
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.avoka.tm.http.HttpRequest
HttpRequest.FileParam, HttpRequest.Param
-
-
Constructor Summary
Constructors Constructor Description PatchRequest(String url)
Create a patch HTTP request object with the given URL.
-
Method Summary
-
Methods inherited from class com.avoka.tm.http.HttpRequest
addFileParam, addHeader, addHeaders, addParam, addParam, execute, getContext, getFileParams, getHeaders, getMessage, getMessageData, getMethod, getParams, getUri, setAcceptCompress, setBasicAuth, setCharacterEncoding, setCompressMessage, setConnectTimeout, setContentType, setContext, setMessage, setMessageData, setNtlmAuth, setParams, setProxy, setProxyAuth, setReadLimit, setSocketFactory, setSocketTimeout, setTimeouts, setUserAgent, setUseSystemProxy, toString
-
-
-
-
Constructor Detail
-
PatchRequest
public PatchRequest(String url)
Create a patch HTTP request object with the given URL.- Parameters:
url
- the request URL (required)
-
-