title: Problems in accessing S3 via AWS Java SDK
body: <p>I'm trying to get and S3 object size via Java AWS SDK (v2), and send it back via HTTP response (this is all inside a HTTP Server using <code>com.sun.net.httpserver.HttpServer</code>). But it doesn't work and shows me the following debug messages.</p>
  <p>What's going wrong here? Am I missing anything?</p>
  <pre><code>        AwsBasicCredentials awsCreds = AwsBasicCredentials.create(
                  AdapterMain.ACCESS_KEY,
                  AdapterMain.SECRET_KEY);
  
          s3Client = S3Client.builder().region(region)
                                      .endpointOverride(URI.create(AdapterMain.S3server))
                                     .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
                                     .build();
                      //TODO
                      HeadObjectRequest getObjectRequest = HeadObjectRequest.builder()
                              .bucket(bucketName).key(&quot;FILES/&quot;+getMD5(id)+&quot;/FILES/&quot;+id+&quot;/&quot;+id+&quot;.txt&quot;).build();
  
                      HeadObjectResponse objectHead = s3Client.headObject(getObjectRequest);
                      long size = objectHead.contentLength();
                      System.out.println(&quot;==================================&quot;+size);
                      response=size+&quot;&quot;;
                      he.sendResponseHeaders(200, response.length());
  </code></pre>
  <p>And here are the logs:</p>
  <pre><code>18:44:14.898 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain - Creating an interceptor chain that will apply interceptors in the following order: [software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor@62ec69e1, software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor@1d17dde7, software.amazon.awssdk.services.s3.internal.handlers.EnableChunkedEncodingInterceptor@339b31af, software.amazon.awssdk.services.s3.internal.handlers.DisableDoubleUrlEncodingInterceptor@3d96c2f6, software.amazon.awssdk.services.s3.internal.handlers.EnableTrailingChecksumInterceptor@3cb417c4, software.amazon.awssdk.services.s3.internal.handlers.CreateMultipartUploadRequestInterceptor@1f6f0d50, software.amazon.awssdk.services.s3.internal.handlers.GetObjectInterceptor@7513515b, software.amazon.awssdk.services.s3.internal.handlers.AsyncChecksumValidationInterceptor@7e99ac7d, software.amazon.awssdk.services.s3.internal.handlers.EndpointAddressInterceptor@620f9e5d, software.amazon.awssdk.services.s3.internal.handlers.ExceptionTranslationInterceptor@56d0ac1, software.amazon.awssdk.services.s3.internal.handlers.GetBucketPolicyInterceptor@6a1b0abe, software.amazon.awssdk.services.s3.internal.handlers.PutObjectInterceptor@5952b9c4, software.amazon.awssdk.services.s3.internal.handlers.SyncChecksumValidationInterceptor@473129c5, software.amazon.awssdk.services.s3.internal.handlers.DecodeUrlEncodedResponseInterceptor@2ae718e0, software.amazon.awssdk.services.s3.internal.handlers.CreateBucketInterceptor@181bb9f8]
  18:44:14.939 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain - Interceptor 'software.amazon.awssdk.services.s3.internal.handlers.EndpointAddressInterceptor@620f9e5d' modified the message with its modifyHttpRequest method.
  18:44:14.967 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.request - Sending Request: DefaultSdkHttpFullRequest(httpMethod=HEAD, protocol=https, host=file-store.s3-server.dcstore.company.net, port=443, encodedPath=/FILES/f13e/FILES/id_1234/id_1234.txt, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[])
  18:44:14.978 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.auth.signer.Aws4Signer - AWS4 String to sign: AWS4-HMAC-SHA256
  20210305T014414Z
  20210305/us-east-1/s3/aws4_request
  9bfed5fd14903f65ac34647985e2c8a4bbe0fbf311982cfbeb2e44b2b58a2390
  18:44:14.991 [HTTP-Dispatcher] WARN software.amazon.awssdk.http.apache.internal.utils.ApacheUtils - NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (&lt; 4.5.8) of Apache http client. It is recommended to use http client version &gt;= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information
  18:44:15.098 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - socket.getSupportedProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3, SSLv2Hello], socket.getEnabledProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1]
  18:44:15.099 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1, TLSv1.3]
  18:44:15.506 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.http.apache.internal.net.SdkSslSocket - created: file-store.s3-server.dcstore.company.net/10.111.111.20:443
  </code></pre>