Class JDKHttpClient
- java.lang.Object
-
- com.github.scribejava.core.httpclient.jdk.JDKHttpClient
-
- All Implemented Interfaces:
HttpClient,java.io.Closeable,java.lang.AutoCloseable
public class JDKHttpClient extends java.lang.Object implements HttpClient
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJDKHttpClient.BodyType
-
Field Summary
Fields Modifier and Type Field Description private JDKHttpClientConfigconfig-
Fields inherited from interface com.github.scribejava.core.httpclient.HttpClient
CONTENT_LENGTH, CONTENT_TYPE, DEFAULT_CONTENT_TYPE
-
-
Constructor Summary
Constructors Constructor Description JDKHttpClient()JDKHttpClient(JDKHttpClientConfig clientConfig)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddBody(java.net.HttpURLConnection connection, byte[] content, boolean requiresBody)private static voidaddBody(java.net.HttpURLConnection connection, MultipartPayload multipartPayload, boolean requiresBody)private static voidaddHeaders(java.net.HttpURLConnection connection, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String userAgent)voidclose()private ResponsedoExecute(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)private <T> java.util.concurrent.Future<T>doExecuteAsync(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, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)Responseexecute(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, byte[] bodyContents)Responseexecute(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, MultipartPayload multipartPayloads)Responseexecute(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, java.io.File bodyContents)Responseexecute(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, java.lang.String bodyContents)<T> java.util.concurrent.Future<T>executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, byte[] bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)<T> java.util.concurrent.Future<T>executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, MultipartPayload bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)<T> java.util.concurrent.Future<T>executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, java.io.File bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)<T> java.util.concurrent.Future<T>executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, java.lang.String bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)private static java.util.Map<java.lang.String,java.lang.String>parseHeaders(java.net.HttpURLConnection conn)private static java.io.OutputStreamprepareConnectionForBodyAndGetOutputStream(java.net.HttpURLConnection connection, int contentLength)
-
-
-
Field Detail
-
config
private final JDKHttpClientConfig config
-
-
Constructor Detail
-
JDKHttpClient
public JDKHttpClient()
-
JDKHttpClient
public JDKHttpClient(JDKHttpClientConfig clientConfig)
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
executeAsync
public <T> java.util.concurrent.Future<T> executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, byte[] bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)- Specified by:
executeAsyncin interfaceHttpClient
-
executeAsync
public <T> java.util.concurrent.Future<T> executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, MultipartPayload bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)- Specified by:
executeAsyncin interfaceHttpClient
-
executeAsync
public <T> java.util.concurrent.Future<T> executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, java.lang.String bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)- Specified by:
executeAsyncin interfaceHttpClient
-
executeAsync
public <T> java.util.concurrent.Future<T> executeAsync(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers, Verb httpVerb, java.lang.String completeUrl, java.io.File bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)- Specified by:
executeAsyncin interfaceHttpClient
-
doExecuteAsync
private <T> java.util.concurrent.Future<T> doExecuteAsync(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, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)
-
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:
executein interfaceHttpClient- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.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:
executein interfaceHttpClient- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.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:
executein interfaceHttpClient- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.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:
executein interfaceHttpClient- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.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
-
-