Class JDKHttpClient

  • All Implemented Interfaces:
    HttpClient, java.io.Closeable, java.lang.AutoCloseable

    public class JDKHttpClient
    extends java.lang.Object
    implements HttpClient
    • Constructor Detail

      • JDKHttpClient

        public JDKHttpClient()
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • execute

        public Response execute​(java.lang.String userAgent,
                                java.util.Map<java.lang.String,​java.lang.String> headers,
                                Verb httpVerb,
                                java.lang.String completeUrl,
                                byte[] bodyContents)
                         throws java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException,
                                java.io.IOException
        Specified by:
        execute in interface HttpClient
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.io.IOException
      • execute

        public Response execute​(java.lang.String userAgent,
                                java.util.Map<java.lang.String,​java.lang.String> headers,
                                Verb httpVerb,
                                java.lang.String completeUrl,
                                MultipartPayload multipartPayloads)
                         throws java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException,
                                java.io.IOException
        Specified by:
        execute in interface HttpClient
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.io.IOException
      • execute

        public Response execute​(java.lang.String userAgent,
                                java.util.Map<java.lang.String,​java.lang.String> headers,
                                Verb httpVerb,
                                java.lang.String completeUrl,
                                java.lang.String bodyContents)
                         throws java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException,
                                java.io.IOException
        Specified by:
        execute in interface HttpClient
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.io.IOException
      • execute

        public Response execute​(java.lang.String userAgent,
                                java.util.Map<java.lang.String,​java.lang.String> headers,
                                Verb httpVerb,
                                java.lang.String completeUrl,
                                java.io.File bodyContents)
                         throws java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException,
                                java.io.IOException
        Specified by:
        execute in interface HttpClient
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.io.IOException
      • doExecute

        private Response doExecute​(java.lang.String userAgent,
                                   java.util.Map<java.lang.String,​java.lang.String> headers,
                                   Verb httpVerb,
                                   java.lang.String completeUrl,
                                   JDKHttpClient.BodyType bodyType,
                                   java.lang.Object bodyContents)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • parseHeaders

        private static java.util.Map<java.lang.String,​java.lang.String> parseHeaders​(java.net.HttpURLConnection conn)
      • addHeaders

        private static void addHeaders​(java.net.HttpURLConnection connection,
                                       java.util.Map<java.lang.String,​java.lang.String> headers,
                                       java.lang.String userAgent)
      • addBody

        private static void addBody​(java.net.HttpURLConnection connection,
                                    byte[] content,
                                    boolean requiresBody)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • addBody

        private static void addBody​(java.net.HttpURLConnection connection,
                                    MultipartPayload multipartPayload,
                                    boolean requiresBody)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • prepareConnectionForBodyAndGetOutputStream

        private static java.io.OutputStream prepareConnectionForBodyAndGetOutputStream​(java.net.HttpURLConnection connection,
                                                                                       int contentLength)
                                                                                throws java.io.IOException
        Throws:
        java.io.IOException