Class SimpleHttpRequest

java.lang.Object
com.nagra.otvaa.sdk.utils.SimpleHttpRequest

public class SimpleHttpRequest extends Object
  • Constructor Details

  • 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 this connection. If the timeout expires before the connection can be established, a SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
      Parameters:
      timeout - an int 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 - an int that specifies the timeout value to be used in milliseconds
    • makeRequest

      public void makeRequest(SimpleHttpRequest.HTTP_METHOD method)
      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

      public Map<String,List<String>> getResponseHeaderFields()
      Get the header fields of the server's response
      Returns:
      The header fields returned by the server
    • getContentType

      public String 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

      public String 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

      public void setHttpConnection(HttpURLConnection connection)