Request sent with version Http/0.9

Posted by user143224 on Server Fault See other posts from Server Fault or by user143224
Published on 2012-10-29T21:23:14Z Indexed on 2012/10/29 23:04 UTC
Read the original article Hit count: 155

Filed under:

I am using common-HttpClient ver 3.1. All my requests are having correct (default) Http version in the request line i.e Http/1.1 except fot 1 request.

Following Post request gets the requestline as Http/0.9 server : port/cas/v1/tickets/TGT-1-sUqenNbqUzvkGSWW25lcbaJc0OEcJ6wg5DOj3XDMSwoIBf6s7i-cas-1 Body: service=*

I debugged through the httpclient code and saw the requestline is set to http/1.1 but on the server i see the request coming as http/0.9. i tried to set the http version explicitly using the HttpMethodParams but does not help. Does someone has any idea what could be wrong?

    HttpClient client = new HttpClient();
    HostConfiguration hc = client.getHostConfiguration();
    hc.setHost(new URI(url, false));

    PostMethod method = new PostMethod();
    method.setURI(new URI(url, false));

    method.getParams().setUriCharset("UTF-8");
    method.getParams().setHttpElementCharset("UTF-8");
    method.getParams().setContentCharset("UTF-8");
    method.getParams().setVersion(HttpVersion.HTTP_1_1);
    method.addParameter("service", URLEncoder.encode(service, "UTF-8"));
    method.setPath(contextPath + "/tickets/" + tgt);

    String  respBody = null;
    int statusCode = client.executeMethod(method);
    respBody = method.getResponseBodyAsString();

© Server Fault or respective owner

Related posts about java