es.gob.fnmt.net.http

## Class HTTPClient

- java.lang.Object
- - es.gob.fnmt.net.http.HTTPClient

-     public class HTTPClient
      extends java.lang.Object

  Simple HTTP client wrapper.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `ShowConnectionTrace`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HTTPClient(java.lang.String url)` 'GET' request.
    `HTTPClient(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> params)` 'POST' request with URL encoded parameters.
    `HTTPClient(java.lang.String url, MultipartData params)` 'POST' request with MultipartData parameters.
    `HTTPClient(java.lang.String url, java.lang.String method)` 'GET' or 'POST' request.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getByteArrayResponse()` Get the response as byte array.
    `byte[]` | `getByteArrayResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)` Get the response as byte array.
    `byte[]` | `getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory)` Get the response as byte array.
    `byte[]` | `getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory, java.util.Map<java.lang.String,java.lang.String> requestProperties)` Get the response as byte array.
    `int` | `getLastResponse()` Get the HTTP response code of the last request.
    `int` | `getResponse()` Establish the connection and returns the status.
    `int` | `getResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)` Establish the connection and returns the status.
    `int` | `getResponse(javax.net.ssl.SSLSocketFactory socketFactory)` Establish the connection and returns the status.
    `int` | `getResponse(javax.net.ssl.SSLSocketFactory socketFactory, java.util.Map<java.lang.String,java.lang.String> requestProperties)` Establish the connection and returns the status.
    `java.io.InputStream` | `getStreamResponse()` Get the response as stream.
    `java.io.InputStream` | `getStreamResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)` Get the response as stream.
    `java.io.InputStream` | `getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory)` Get the response as stream.
    `java.io.InputStream` | `getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory, java.util.Map<java.lang.String,java.lang.String> requestProperties)` Get the response as stream.
    `java.lang.String` | `getStringResponse()` Get the response as string encoded in 'UTF-8'.
    `java.lang.String` | `getStringResponse(java.nio.charset.Charset charset)` Get the response as string.
    `java.lang.String` | `getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)` Get the response as string encoded in 'UTF-8'.
    `java.lang.String` | `getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties, java.nio.charset.Charset charset)` Get the response as string.
    `java.lang.String` | `getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory)` Get the response as string encoded in 'UTF-8'.
    `java.lang.String` | `getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory, java.nio.charset.Charset charset)` Get the response as string.
    `java.lang.String` | `getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory, java.util.Map<java.lang.String,java.lang.String> requestProperties)` Get the response as string.
    `java.lang.String` | `getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory, java.util.Map<java.lang.String,java.lang.String> requestProperties, java.nio.charset.Charset charset)` Get the response as string.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ShowConnectionTrace

          public static boolean ShowConnectionTrace

  - ### Constructor Detail

    - #### HTTPClient

          public HTTPClient(java.lang.String url)

      'GET' request.
      Parameters:
        `url` - URL to connect.

    - #### HTTPClient

          public HTTPClient(java.lang.String url,
                            java.util.Map<java.lang.String,java.lang.String> params)

      'POST' request with URL encoded parameters.
      Parameters:
        `url` - URL to connect.
        `params` - List of pair parameter name and value to send.

    - #### HTTPClient

          public HTTPClient(java.lang.String url,
                            MultipartData params)

      'POST' request with MultipartData parameters.
      Parameters:
        `url` - URL to connect.
        `params` - MultipartData parameter data to send.

    - #### HTTPClient

          public HTTPClient(java.lang.String url,
                            java.lang.String method)

      'GET' or 'POST' request.
      Parameters:
        `url` - URL to connect.
        `method` - 'GET' or 'POST'.

  - ### Method Detail

    - #### getByteArrayResponse

          public byte[] getByteArrayResponse()
                                      throws java.io.IOException

      Get the response as byte array.
      Returns:
        Content of the response body as byte array.
      Throws:
        `java.io.IOException`

    - #### getByteArrayResponse

          public byte[] getByteArrayResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
                                      throws java.io.IOException

      Get the response as byte array.
      Parameters:
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        Content of the response body as byte array.
      Throws:
        `java.io.IOException`

    - #### getByteArrayResponse

          public byte[] getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory)
                                      throws java.io.IOException

      Get the response as byte array.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
      Returns:
        Content of the response body as byte array.
      Throws:
        `java.io.IOException`

    - #### getByteArrayResponse

          public byte[] getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory,
                                             java.util.Map<java.lang.String,java.lang.String> requestProperties)
                                      throws java.io.IOException

      Get the response as byte array.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        Content of the response body as byte array.
      Throws:
        `java.io.IOException`

    - #### getLastResponse

          public int getLastResponse()
                              throws java.io.IOException

      Get the HTTP response code of the last request.
      Returns:
        HTTP response code.
      Throws:
        `java.io.IOException` - if there is no previous request.

    - #### getResponse

          public int getResponse()
                          throws java.io.IOException

      Establish the connection and returns the status.
      Returns:
        HTTP code indicating the status of the connection.
      Throws:
        `java.io.IOException`

    - #### getResponse

          public int getResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
                          throws java.io.IOException

      Establish the connection and returns the status.
      Parameters:
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        HTTP response code indicating the status of the connection.
      Throws:
        `java.io.IOException`

    - #### getResponse

          public int getResponse(javax.net.ssl.SSLSocketFactory socketFactory)
                          throws java.io.IOException

      Establish the connection and returns the status.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
      Returns:
        HTTP response code indicating the status of the connection.
      Throws:
        `java.io.IOException`

    - #### getResponse

          public int getResponse(javax.net.ssl.SSLSocketFactory socketFactory,
                                 java.util.Map<java.lang.String,java.lang.String> requestProperties)
                          throws java.io.IOException

      Establish the connection and returns the status.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        HTTP response code indicating the status of the connection.
      Throws:
        `java.io.IOException`

    - #### getStreamResponse

          public java.io.InputStream getStreamResponse()
                                                throws java.io.IOException

      Get the response as stream.
      Returns:
        Stream with the content response.
      Throws:
        `java.io.IOException`

    - #### getStreamResponse

          public java.io.InputStream getStreamResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
                                                throws java.io.IOException

      Get the response as stream.
      Parameters:
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        Stream with the content response.
      Throws:
        `java.io.IOException`

    - #### getStreamResponse

          public java.io.InputStream getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory)
                                                throws java.io.IOException

      Get the response as stream.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
      Returns:
        Stream with the content response.
      Throws:
        `java.io.IOException`

    - #### getStreamResponse

          public java.io.InputStream getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory,
                                                       java.util.Map<java.lang.String,java.lang.String> requestProperties)
                                                throws java.io.IOException

      Get the response as stream.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        Stream with the content response.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse()
                                             throws java.io.IOException

      Get the response as string encoded in 'UTF-8'.
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(java.nio.charset.Charset charset)
                                             throws java.io.IOException

      Get the response as string.
      Parameters:
        `charset` - Character encoding.
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
                                             throws java.io.IOException

      Get the response as string encoded in 'UTF-8'.
      Parameters:
        `requestProperties` - List of pair property and value to specify in the request.
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties,
                                                    java.nio.charset.Charset charset)
                                             throws java.io.IOException

      Get the response as string.
      Parameters:
        `requestProperties` - List of pair property and value to specify in the request.
        `charset` - Character encoding.
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory)
                                             throws java.io.IOException

      Get the response as string encoded in 'UTF-8'.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
                                                    java.nio.charset.Charset charset)
                                             throws java.io.IOException

      Get the response as string.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
        `charset` - Character encoding.
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
                                                    java.util.Map<java.lang.String,java.lang.String> requestProperties)
                                             throws java.io.IOException

      Get the response as string.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
        `requestProperties` -
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`

    - #### getStringResponse

          public java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
                                                    java.util.Map<java.lang.String,java.lang.String> requestProperties,
                                                    java.nio.charset.Charset charset)
                                             throws java.io.IOException

      Get the response as string.
      Parameters:
        `socketFactory` - Underlying factory of sockets to use by the connection.
        `requestProperties` - List of pair property and value to specify in the request.
        `charset` -
      Returns:
        Content of the response body as string.
      Throws:
        `java.io.IOException`