Package com.nagra.otvaa.sdk.utils
Class SimpleHttpRequest
java.lang.Object
com.nagra.otvaa.sdk.utils.SimpleHttpRequest
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static interface
Callback that notifies on success or failure of an HTTP request. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleHttpRequest
(String requestUrl, Map<String, String> requestProperties, byte[] requestData) SimpleHttpRequest
(String requestUrl, Map<String, String> requestProperties, byte[] requestData, SimpleHttpRequest.ResponseHandler responseHandler) -
Method Summary
Modifier and TypeMethodDescriptionGet the content type received for the HTTP requestGet the error message of a failed requestint
Get the server's response code e.g.byte[]
Get the body of the server's responseGet the header fields of the server's responsevoid
Execute an HTTP request to the URL supplied in the constructor, with the properties and (optionally) request body provided.void
setConnectTimeout
(int timeout) Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by thisconnection
.void
setHttpConnection
(HttpURLConnection connection) void
setReadTimeout
(int timeout) Sets the read timeout to a specified timeout, in milliseconds.
-
Constructor Details
-
SimpleHttpRequest
public SimpleHttpRequest(String requestUrl, @Nullable Map<String, String> requestProperties, @Nullable byte[] requestData, @Nullable SimpleHttpRequest.ResponseHandler responseHandler) -
SimpleHttpRequest
-
-
Method Details
-
setConnectTimeout
public void setConnectTimeout(int timeout) Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by thisconnection
. If the timeout expires before the connection can be established, aSocketTimeoutException
is raised. A timeout of zero is interpreted as an infinite timeout.- Parameters:
timeout
- anint
that specifies the connect timeout value in milliseconds
-
setReadTimeout
public void setReadTimeout(int timeout) Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.- Parameters:
timeout
- anint
that specifies the timeout value to be used in milliseconds
-
makeRequest
Execute an HTTP request to the URL supplied in the constructor, with the properties and (optionally) request body provided.- Parameters:
method
- The HTTP method to execute (GET, PUT, POST or HEADER)
-
getResponseCode
public int getResponseCode()Get the server's response code e.g. 200 (OK)- Returns:
- The response code returned by the server
-
getResponseHeaderFields
Get the header fields of the server's response- Returns:
- The header fields returned by the server
-
getContentType
Get the content type received for the HTTP request- Returns:
- The content-type string
-
getResponseData
public byte[] getResponseData()Get the body of the server's response- Returns:
- The complete response body returned by the server
-
getErrorMessage
Get the error message of a failed request- Returns:
- An error message describing the reason for a failed request (empty string if none)
-
setHttpConnection
-