hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srikalyan swayampakula <srikalyansswa...@gmail.com>
Subject Re: ClientProtocolException for 204 No Content as response header
Date Sat, 12 Jul 2014 15:20:04 GMT
Also, I forgot to mention this. This seems to happen with alternative calls.


On Sat, Jul 12, 2014 at 8:18 AM, srikalyan swayampakula <
srikalyansswayam@gmail.com> wrote:

>
> Hi,
>
> I am getting a ClientProtocolException for a delete request. The response
> is "204 No Content" and seems to be a bug in httpclient.
>
> I am creating the transport like this
>
> transport = new ApacheHttpTransport();
>
>        final RequestConfig defaultRequestConfig = RequestConfig.DEFAULT;
>
>        final RegistryBuilder<ConnectionSocketFactory> builder =
>                 RegistryBuilder.<ConnectionSocketFactory>create()
>                                .register("http",
> PlainConnectionSocketFactory.getSocketFactory());
>
>        // allow a customized SSLConnectionSocketFactory to be used
>        if (this.sslConnectionSocketFactory != null) {
>           builder.register("https", this.sslConnectionSocketFactory);
>        } else {
>           builder.register("https",
> SSLConnectionSocketFactory.getSocketFactory());
>        }
>
>        final Registry<ConnectionSocketFactory> registry = builder.build();
>
>        final PoolingHttpClientConnectionManager cm =
>           new PoolingHttpClientConnectionManager(registry);
>
>        // Increase max total connection
>        cm.setMaxTotal(this.maxConnections);
>        // Increase default max connection per route
>        cm.setDefaultMaxPerRoute(this.maxConnections);
>        //close expired connections
>        cm.closeExpiredConnections();
>
>
>
>        final HttpClient client = HttpClientBuilder.create()
>                                                   .setConnectionManager(cm)
>
> .setDefaultRequestConfig(defaultRequestConfig)
>
> .setMaxConnPerRoute(this.maxConnections)
>
> .setConnectionReuseStrategy(
>
>  DefaultConnectionReuseStrategy.INSTANCE)
>                                                   .build();
>
>        transport.setClient(client);
>        transport.setServerUrl(serverUrl);
>        transport.setUsername(username);
>        transport.setPassword(password);
>        transport.setBasicAuth(hasText(username) || hasText(password));
>
>        return transport;
>
> and calling transport.delete(httpparams) and the server it is trying to
> call seem to be fine no stack trace and access log seems behave as expected.
>
>  I enabled some debug logging which is indicating that there might be a
> bug with the library
>
> Sat Jul 12 07:22:33.516 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: HTTP/1.1 204 No Content
> Sat Jul 12 07:22:33.516 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Date: Sat, 12 Jul 2014 14:22:33 GMT
> Sat Jul 12 07:22:33.516 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Server: Apache
> Sat Jul 12 07:22:33.517 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Access-Control-Allow-Origin: *
> Sat Jul 12 07:22:33.517 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Access-Control-Allow-Methods: GET, POST, PUT, DELE
> TE, OPTIONS
> Sat Jul 12 07:22:33.517 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Access-Control-Allow-Headers: Authorization, Conte
> nt-Type
> Sat Jul 12 07:22:33.517 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Access-Control-Max-Age: 86400
> Sat Jul 12 07:22:33.518 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Content-Encoding: gzip
> Sat Jul 12 07:22:33.518 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Content-Length: 20
> Sat Jul 12 07:22:33.518 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Keep-Alive: timeout=15, max=65
> Sat Jul 12 07:22:33.518 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Connection: Keep-Alive
> Sat Jul 12 07:22:33.519 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response: Content-Type: application/json;charset=UTF-8
> Sat Jul 12 07:22:33.519 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response:
> Sat Jul 12 07:22:48.532 PDT 2014 | "ajp-bio-8009"-exec-2 |
> org.apache.http.impl.conn.DefaultHttpResponseParser | DEBUG | Garbage in
> response:
>
>
> The root cause is
> Caused by: org.apache.http.ProtocolException: The server failed to respond
> with a valid HTTP response
>         at
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:151)
>         at
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
>         at
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260)
>         at
> org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:161)
>         at
> org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:153)
>         at
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271)
>         at
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
>         at
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
>         at
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
>         at
> org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
>         at
> org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
>         at
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
>
>
> Please let me know if I am doing something wrong and thanks in advance.
>
> --
>
> -SK.
>



-- 

-SK.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message