Repository: calcite-avatica Updated Branches: refs/heads/master f0bce9859 -> e4c1a0426
CALCITE-2503 AvaticaCommonsHttpClientImpl client needs to set user-token on HttpClientContext before sending the request Closes #67 Signed-off-by: Josh Elser <els...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica/commit/e4c1a042 Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica/tree/e4c1a042 Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica/diff/e4c1a042 Branch: refs/heads/master Commit: e4c1a0426692b52aac488d7e1e5bcb90934e1a17 Parents: f0bce98 Author: Karan Mehta <karanmeht...@gmail.com> Authored: Fri Sep 7 16:31:56 2018 -0700 Committer: Josh Elser <els...@apache.org> Committed: Fri Sep 7 16:32:28 2018 -0700 ---------------------------------------------------------------------- .../calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/e4c1a042/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java index 0981efe..ba9f9c6 100644 --- a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java +++ b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java @@ -87,6 +87,7 @@ public class AvaticaCommonsHttpClientImpl implements AvaticaHttpClient, protected UsernamePasswordCredentials credentials = null; protected CredentialsProvider credentialsProvider = null; protected Lookup<AuthSchemeProvider> authRegistry = null; + protected Object userToken; protected File truststore = null; protected File keystore = null; @@ -205,6 +206,10 @@ public class AvaticaCommonsHttpClientImpl implements AvaticaHttpClient, context.setAuthCache(authCache); } + if (null != userToken) { + context.setUserToken(userToken); + } + ByteArrayEntity entity = new ByteArrayEntity(request, ContentType.APPLICATION_OCTET_STREAM); // Create the client with the AuthSchemeRegistry and manager @@ -215,6 +220,7 @@ public class AvaticaCommonsHttpClientImpl implements AvaticaHttpClient, final int statusCode = response.getStatusLine().getStatusCode(); if (HttpURLConnection.HTTP_OK == statusCode || HttpURLConnection.HTTP_INTERNAL_ERROR == statusCode) { + userToken = context.getUserToken(); return EntityUtils.toByteArray(response.getEntity()); } else if (HttpURLConnection.HTTP_UNAVAILABLE == statusCode) { LOG.debug("Failed to connect to server (HTTP/503), retrying");