Class HttpTransportClient

  • All Implemented Interfaces:
    TransportClient

    public class HttpTransportClient
    extends java.lang.Object
    implements TransportClient
    Created by Anton Tsivarev on 11.09.15.
    • Field Detail

      • LOG

        protected static final org.slf4j.Logger LOG
      • FORM_CONTENT_TYPE

        protected static final java.lang.String FORM_CONTENT_TYPE
        See Also:
        Constant Field Values
      • CONTENT_TYPE_HEADER

        protected static final java.lang.String CONTENT_TYPE_HEADER
        See Also:
        Constant Field Values
      • MAX_SIMULTANEOUS_CONNECTIONS

        protected static final int MAX_SIMULTANEOUS_CONNECTIONS
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_ATTEMPTS_NETWORK_ERROR_COUNT

        protected static final int DEFAULT_RETRY_ATTEMPTS_NETWORK_ERROR_COUNT
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_INVALID_STATUS_COUNT

        protected static final int DEFAULT_RETRY_INVALID_STATUS_COUNT
        See Also:
        Constant Field Values
      • FULL_CONNECTION_TIMEOUT_S

        protected static final int FULL_CONNECTION_TIMEOUT_S
        See Also:
        Constant Field Values
      • CONNECTION_TIMEOUT_MS

        protected static final int CONNECTION_TIMEOUT_MS
        See Also:
        Constant Field Values
      • httpClient

        protected static org.apache.http.client.HttpClient httpClient
      • retryAttemptsNetworkErrorCount

        protected int retryAttemptsNetworkErrorCount
      • retryAttemptsInvalidStatusCount

        protected int retryAttemptsInvalidStatusCount
    • Constructor Detail

      • HttpTransportClient

        public HttpTransportClient()
      • HttpTransportClient

        public HttpTransportClient​(int retryAttemptsNetworkErrorCount,
                                   int retryAttemptsInvalidStatusCount)
    • Method Detail

      • getHeaders

        protected static java.util.Map<java.lang.String,​java.lang.String> getHeaders​(org.apache.http.Header[] headers)
      • callWithStatusCheck

        protected ClientResponse callWithStatusCheck​(org.apache.http.client.methods.HttpRequestBase request)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • isInvalidGatewayStatus

        protected boolean isInvalidGatewayStatus​(int status)
      • call

        protected ClientResponse call​(org.apache.http.client.methods.HttpRequestBase request)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • logRequest

        protected void logRequest​(org.apache.http.client.methods.HttpRequestBase request)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • getRequestPayload

        protected java.lang.String getRequestPayload​(org.apache.http.client.methods.HttpRequestBase request)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • logRequest

        protected void logRequest​(org.apache.http.client.methods.HttpRequestBase request,
                                  java.util.Map<java.lang.String,​java.lang.String> requestHeaders,
                                  org.apache.http.HttpResponse response,
                                  java.util.Map<java.lang.String,​java.lang.String> responseHeaders,
                                  java.lang.String body,
                                  java.lang.Long time)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • get

        public ClientResponse get​(java.lang.String url)
                           throws java.io.IOException
        Specified by:
        get in interface TransportClient
        Throws:
        java.io.IOException
      • get

        public ClientResponse get​(java.lang.String url,
                                  java.lang.String contentType)
                           throws java.io.IOException
        Specified by:
        get in interface TransportClient
        Throws:
        java.io.IOException
      • get

        public ClientResponse get​(java.lang.String url,
                                  org.apache.http.Header[] headers)
                           throws java.io.IOException
        Specified by:
        get in interface TransportClient
        Throws:
        java.io.IOException
      • post

        public ClientResponse post​(java.lang.String url)
                            throws java.io.IOException
        Specified by:
        post in interface TransportClient
        Throws:
        java.io.IOException
      • post

        public ClientResponse post​(java.lang.String url,
                                   java.lang.String body)
                            throws java.io.IOException
        Specified by:
        post in interface TransportClient
        Throws:
        java.io.IOException
      • post

        public ClientResponse post​(java.lang.String url,
                                   java.lang.String body,
                                   java.lang.String contentType)
                            throws java.io.IOException
        Specified by:
        post in interface TransportClient
        Throws:
        java.io.IOException
      • post

        public ClientResponse post​(java.lang.String url,
                                   java.lang.String body,
                                   org.apache.http.Header[] headers)
                            throws java.io.IOException
        Specified by:
        post in interface TransportClient
        Throws:
        java.io.IOException
      • post

        public ClientResponse post​(java.lang.String url,
                                   java.lang.String fileName,
                                   java.io.File file)
                            throws java.io.IOException
        Specified by:
        post in interface TransportClient
        Throws:
        java.io.IOException
      • delete

        public ClientResponse delete​(java.lang.String url,
                                     java.lang.String body)
                              throws java.io.IOException
        Specified by:
        delete in interface TransportClient
        Throws:
        java.io.IOException
      • delete

        public ClientResponse delete​(java.lang.String url,
                                     java.lang.String body,
                                     java.lang.String contentType)
                              throws java.io.IOException
        Specified by:
        delete in interface TransportClient
        Throws:
        java.io.IOException
      • delete

        public ClientResponse delete​(java.lang.String url,
                                     java.lang.String body,
                                     org.apache.http.Header[] headers)
                              throws java.io.IOException
        Specified by:
        delete in interface TransportClient
        Throws:
        java.io.IOException