You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Amol Kulkarni <am...@AppPerfect.com> on 2005/06/16 12:33:23 UTC

Problem with HttpConnectionManager

 Hi ,

I am using HttpClient as a Proxy Recorder i.e. An request made through Browser goes through my code and I am using HttpClient to fire the browser request. The response that I get from HttpMethod is written back to the Browser. I facing a problem (which I feel is a bug in HttpClient).

To test my Proxy Recorder I have configured the PetStore demo.

Very briefly, The first URL that I fire (or execute using HttpClient) is 

http://localhost:8080/petstore/signon_welcome.screen

[DEBUG] header - >> "GET /petstore/signon_welcome.screen HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*[\r][\n]"
[DEBUG] header - >> "Accept-Language: en-us[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)[\r][\n]"
[DEBUG] header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] header - << "Set-Cookie: JSESSIONID=E3EC131BD85879A0BAF747C2AF373DED; Path=/petstore[\r][\n]"
[DEBUG] header - << "Content-Type: text/html;charset=UTF-8[\r][\n]"
[DEBUG] header - << "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] header - << "Date: Thu, 16 Jun 2005 09:55:19 GMT[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"

The response is a form which has 2 forms, one for Signing in and another for registering a New User.

I submit the first form by clicking the "Sign In" button.

[DEBUG] header - >> "POST /petstore/j_signon_check HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*[\r][\n]"
[DEBUG] header - >> "Referer: http://localhost:8080/petstore/signon_welcome.screen[\r][\n]"
[DEBUG] header - >> "Accept-Language: en-us[\r][\n]"
[DEBUG] header - >> "Content-Type: application/x-www-form-urlencoded[\r][\n]"
[DEBUG] header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)[\r][\n]"
[DEBUG] header - >> "Content-Length: 46[\r][\n]"
[DEBUG] header - >> "Pragma: no-cache[\r][\n]"
[DEBUG] header - >> "Cookie: JSESSIONID=E3EC131BD85879A0BAF747C2AF373DED[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] HttpMethodBase - Default charset used: ISO-8859-1
[DEBUG] HttpMethodBase - Default charset used: ISO-8859-1
[DEBUG] content - >> "j_username=j2ee&j_password=j2ee&submit=Sign%2BIn"
[DEBUG] EntityEnclosingMethod - Request body sent
[DEBUG] header - << "HTTP/1.1 302 Moved Temporarily[\r][\n]"
[DEBUG] header - << "Location: http://localhost:8080/petstore/signon_welcome.screen[\r][\n]"
[DEBUG] header - << "Content-Length: 0[\r][\n]"
[DEBUG] header - << "Date: Thu, 16 Jun 2005 09:55:38 GMT[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"
[DEBUG] HttpMethodDirector - Redirect required
[DEBUG] header - >> "GET /petstore/signon_welcome.screen HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*[\r][\n]"
[DEBUG] header - >> "Referer: http://localhost:8080/petstore/signon_welcome.screen[\r][\n]"
[DEBUG] header - >> "Accept-Language: en-us[\r][\n]"
[DEBUG] header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)[\r][\n]"
[DEBUG] header - >> "Pragma: no-cache[\r][\n]"
[DEBUG] header - >> "Cookie: JSESSIONID=E3EC131BD85879A0BAF747C2AF373DED[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] header - << "HTTP/1.1 501 Method InGET is not defined in RFC 2068 and is not supported by the Servlet API [\r][\n]"
[DEBUG] header - << "Content-Type: text/html;charset=utf-8[\r][\n]"
[DEBUG] header - << "Content-Length: 1229[\r][\n]"
[DEBUG] header - << "Date: Thu, 16 Jun 2005 09:55:38 GMT[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"
[DEBUG] header - << "Connection: close[\r][\n]"
[DEBUG] content - << "<html><head><title>Apache Tomcat/5.0.28 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 501 - Method InGET is not defined in RFC 2068 and is not supported by the Servlet API </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Method InGET is not defined in RFC 2068 and is not supported by the Servlet API </u></p><p><b>description</b> <u>The server does not support the functionality needed to fulfill this request (Method InGET is not defined in RFC 2068 and is not supported by the Servlet API ).</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.0.28</h3></body></html>"
[DEBUG] HttpMethodBase - Should close connection in response to directive: close
[DEBUG] HttpConnection - Releasing connection back to connection manager.


 The expected behaviour is that the user logs in to the Store, But On submitting this request, I get 

"HTTP Status 501 - Method InGET is not defined in RFC 2068 and is not supported by the Servlet API "

Note the Method "InGet", The "In" is actually value of the last parameter sent in the Post Method.

[DEBUG] content - >> "j_username=j2ee&j_password=j2ee&submit=Sign%2BIn"

I have checked this with some other Post method submits in the Petstore demo itself, And I am getting end characters of the Post method's request data.

I am attaching the trace.log file with this mail. Note that I am handling the Redirection in my code, hence I have set the redirection to false.

I have performed the "Things To Try", and this happens only when my code sits between Browser and server. I have debugged the problem, And If I create the MultiThreadedHttpConnectionManager every time I create an object of HttpMethod and set it to HttpClient's reference, this problem doesn't arise i.e. The response on submitting the form is proper one. I know that MultiThreadedHttpConnectionManager should not be created every time.

Please let me know If I am doing something wrong or is this a bug in HttpClient's code? I have also tried this with the nighty build. My code is also based on the tutorial i.e. the sequence of API's being called are in the same sequence.


Eagerly waiting for your response.

Regards,
Amol Kulkarni.



Re: Problem with HttpConnectionManager

Posted by Roland Weber <RO...@de.ibm.com>.
Hello Amol,

first some formalities:

1) Please do not cross-post the same message to different mailing lists.
   The discussions in the mailing lists will drift apart, and everyone
   who is not subscribed to all lists will not get the full picture.

2) Please post plain text mails, not HTML mails.

3) Large attachments will be removed by the mailing list server.

now to the technical part:

Your proxy implementation is defective. In particular, you are sending
a Content-Length header of 46, but a message body with 48 bytes. Please
check the relevant sections of RFC 2616. Some headers must be passed
on by a proxy, others removed, and some need to be adjusted depending
on what the proxy does.
In your particular case, don't set the Content-Length header nor the
Transfer-Encoding header. HttpClient will take care of such things.

If you create a new connection manager, you effectively disable
connection re-use. The problem is that the server stops reading the
message body after 46 bytes, but you send 48. If the connection is
re-used, the two additional bytes will be considered part of the
next HTTP message, with the result you witnessed. If the connection
is not re-used, the two bytes will just be missing from the data
that the server receives. Either way, your proxy is broken.

hope that helps,
  Roland





"Amol Kulkarni" <am...@AppPerfect.com> 
16.06.2005 12:33
Please respond to
"HttpClient Project"


To
<ht...@jakarta.apache.org>
cc
<ht...@jakarta.apache.org>
Subject
Problem with HttpConnectionManager






 Hi ,
 
I am using HttpClient as a Proxy Recorder i.e. An request made through 
Browser goes through my code and I am using HttpClient to fire the browser 
request. The response that I get from HttpMethod is written back to the 
Browser. I facing a problem (which I feel is a bug in HttpClient).
 
To test my Proxy Recorder I have configured the PetStore demo.
 
Very briefly, The first URL that I fire (or execute using HttpClient) is 
 
http://localhost:8080/petstore/signon_welcome.screen
 
[DEBUG] header - >> "GET /petstore/signon_welcome.screen HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "Accept: image/gif, image/x-xbitmap, image/jpeg, 
image/pjpeg, application/x-shockwave-flash, */*[\r][\n]"
[DEBUG] header - >> "Accept-Language: en-us[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; 
Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)[\r][\n]"
[DEBUG] header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] header - << "Set-Cookie: 
JSESSIONID=E3EC131BD85879A0BAF747C2AF373DED; Path=/petstore[\r][\n]"
[DEBUG] header - << "Content-Type: text/html;charset=UTF-8[\r][\n]"
[DEBUG] header - << "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] header - << "Date: Thu, 16 Jun 2005 09:55:19 GMT[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"
The response is a form which has 2 forms, one for Signing in and another 
for registering a New User.
 
I submit the first form by clicking the "Sign In" button.
 
[DEBUG] header - >> "POST /petstore/j_signon_check HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "Accept: image/gif, image/x-xbitmap, image/jpeg, 
image/pjpeg, application/x-shockwave-flash, */*[\r][\n]"
[DEBUG] header - >> "Referer: 
http://localhost:8080/petstore/signon_welcome.screen[\r][\n]"
[DEBUG] header - >> "Accept-Language: en-us[\r][\n]"
[DEBUG] header - >> "Content-Type: 
application/x-www-form-urlencoded[\r][\n]"
[DEBUG] header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; 
Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)[\r][\n]"
[DEBUG] header - >> "Content-Length: 46[\r][\n]"
[DEBUG] header - >> "Pragma: no-cache[\r][\n]"
[DEBUG] header - >> "Cookie: 
JSESSIONID=E3EC131BD85879A0BAF747C2AF373DED[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] HttpMethodBase - Default charset used: ISO-8859-1
[DEBUG] HttpMethodBase - Default charset used: ISO-8859-1
[DEBUG] content - >> "j_username=j2ee&j_password=j2ee&submit=Sign%2BIn"
[DEBUG] EntityEnclosingMethod - Request body sent
[DEBUG] header - << "HTTP/1.1 302 Moved Temporarily[\r][\n]"
[DEBUG] header - << "Location: 
http://localhost:8080/petstore/signon_welcome.screen[\r][\n]"
[DEBUG] header - << "Content-Length: 0[\r][\n]"
[DEBUG] header - << "Date: Thu, 16 Jun 2005 09:55:38 GMT[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"
[DEBUG] HttpMethodDirector - Redirect required
[DEBUG] header - >> "GET /petstore/signon_welcome.screen HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "Accept: image/gif, image/x-xbitmap, image/jpeg, 
image/pjpeg, application/x-shockwave-flash, */*[\r][\n]"
[DEBUG] header - >> "Referer: 
http://localhost:8080/petstore/signon_welcome.screen[\r][\n]"
[DEBUG] header - >> "Accept-Language: en-us[\r][\n]"
[DEBUG] header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; 
Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)[\r][\n]"
[DEBUG] header - >> "Pragma: no-cache[\r][\n]"
[DEBUG] header - >> "Cookie: 
JSESSIONID=E3EC131BD85879A0BAF747C2AF373DED[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] header - << "HTTP/1.1 501 Method InGET is not defined in RFC 2068 
and is not supported by the Servlet API [\r][\n]"
[DEBUG] header - << "Content-Type: text/html;charset=utf-8[\r][\n]"
[DEBUG] header - << "Content-Length: 1229[\r][\n]"
[DEBUG] header - << "Date: Thu, 16 Jun 2005 09:55:38 GMT[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"
[DEBUG] header - << "Connection: close[\r][\n]"
[DEBUG] content - << "<html><head><title>Apache Tomcat/5.0.28 - Error 
report</title><style><!--H1 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} 
H2 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} 
H3 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} 
BODY 
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} 
B 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} 
P 
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A 
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style> 
</head><body><h1>HTTP Status 501 - Method InGET is not defined in RFC 2068 
and is not supported by the Servlet API </h1><HR size="1" 
noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> 
<u>Method InGET is not defined in RFC 2068 and is not supported by the 
Servlet API </u></p><p><b>description</b> <u>The server does not support 
the functionality needed to fulfill this request (Method InGET is not 
defined in RFC 2068 and is not supported by the Servlet API ).</u></p><HR 
size="1" noshade="noshade"><h3>Apache Tomcat/5.0.28</h3></body></html>"
[DEBUG] HttpMethodBase - Should close connection in response to directive: 
close
[DEBUG] HttpConnection - Releasing connection back to connection manager.
 
 The expected behaviour is that the user logs in to the Store, But On 
submitting this request, I get 

"HTTP Status 501 - Method InGET is not defined in RFC 2068 and is not 
supported by the Servlet API "
 
Note the Method "InGet", The "In" is actually value of the last parameter 
sent in the Post Method.
 
[DEBUG] content - >> "j_username=j2ee&j_password=j2ee&submit=Sign%2BIn"
 
I have checked this with some other Post method submits in the Petstore 
demo itself, And I am getting end characters of the Post method's request 
data.
 
I am attaching the trace.log file with this mail. Note that I am handling 
the Redirection in my code, hence I have set the redirection to false.
 
I have performed the "Things To Try", and this happens only when my code 
sits between Browser and server. I have debugged the problem, And If I 
create the MultiThreadedHttpConnectionManager every time I create an 
object of HttpMethod and set it to HttpClient's reference, this problem 
doesn't arise i.e. The response on submitting the form is proper one. I 
know that MultiThreadedHttpConnectionManager should not be created every 
time.
 
Please let me know If I am doing something wrong or is this a bug in 
HttpClient's code? I have also tried this with the nighty build. My code 
is also based on the tutorial i.e. the sequence of API's being called are 
in the same sequence.
 
 
Eagerly waiting for your response.
 
Regards,
Amol Kulkarni.
 
 
 ---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org