You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Tony Seebregts <to...@cibecs.com> on 2005/06/09 16:45:37 UTC
Unbuffered entity enclosing request can not be repeated
Hi,
I'm using the HttpClient to POST a request to the server with the
Content-Length set to CONTENT_LENGTH_CHUNKED.
It works fine with pre-emptive BASIC authentication but fails with an
"Unbuffered entity enclosing request
can not be repeated" with anything else.
Tracing the request it seems that the HttpClient attempts to read the
request body twice - at a guess before the authentication
challenge and then again when authenticated.
The workaround I have for now is to 'ignore' the first request (actually
send an empty body) and then send the real data
through on the second writeRequestBody() call.
This seems more than a bit flaky - does anybody have a better solution ?
Regards
Tony Seebregts
RE: Unbuffered entity enclosing request can not be repeated
Posted by Tony Seebregts <to...@cibecs.com>.
Hi Oleg,
Upgraded to HttpClient 3.0 and it works like a dream. Thanks for the help.
Regards
Tony
-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org]
Sent: 10 June 2005 17:17
To: 'HttpClient User Discussion'
Subject: Re: Unbuffered entity enclosing request can not be repeated
Tony,
HttpClient 2.x cant handle certain types of redirect (cross-site,
cross-port redirects to be exact). In other words it can't redirect from
a plain HTTP url to a HTTPS url without some extra help. For details
see:
http://jakarta.apache.org/commons/httpclient/redirects.html
Consider upgrading to HttpClient 3.0 that does not have this limitation
http://jakarta.apache.org/commons/httpclient/3.0/index.html
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Unbuffered entity enclosing request can not be repeated
Posted by Oleg Kalnichevski <ol...@apache.org>.
Tony,
HttpClient 2.x cant handle certain types of redirect (cross-site,
cross-port redirects to be exact). In other words it can't redirect from
a plain HTTP url to a HTTPS url without some extra help. For details
see:
http://jakarta.apache.org/commons/httpclient/redirects.html
Consider upgrading to HttpClient 3.0 that does not have this limitation
http://jakarta.apache.org/commons/httpclient/3.0/index.html
Oleg
On Fri, Jun 10, 2005 at 05:09:28PM +0200, Tony Seebregts wrote:
> Thanks Oleg, was afraid that might be the answer. Sounds like it's a bit of
> a grey area in the HTTP spec.
>
> While I'm asking questions - if I implement a custom SSL protocol handler
> and register it as the handler for SSL the server sends back a '302 - Moved
> temporarily' response which causes the HttpClient to generate a 'cannot
> follow redirect' type error.
>
> It works fine if I just use the standard SSL protocol handler - but the
> EasySSLProtocolSocketFactory and StrictSSLProtocolSocketFactory throw the
> exception.
>
> Any ideas ? The wire log is below:
>
> Regards
>
> Tony
>
>
>
> DEBUG [httpclient.wire.header] >> "GET /guest HTTP/1.1[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Authorization: Basic
> YWdlbnR4OjAwNw==[\r][\n]"
> DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
> Commons-HttpClient/2.0.2[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Host: localhost:8443[\r][\n]"
> DEBUG [httpclient.wire.header] >> "[\r][\n]"
>
> DEBUG [httpclient.wire.header] << "HTTP/1.1 302 Moved Temporarily[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 10:49:20
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
> x86 java/1.5.0_02[\r][\n]"
> DEBUG [httpclient.wire.header] << "Location:
> https://localhost:8443/guest/[\r][\n]"
> DEBUG [httpclient.wire.header] << "Transfer-Encoding: chunked[\r][\n]"
>
> DEBUG [httpclient.wire.header] >> "GET /guest/ HTTP/1.1[\r][\n]"
> DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
> Commons-HttpClient/2.0.2[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Host: localhost:8443[\r][\n]"
> DEBUG [httpclient.wire.header] >> "[\r][\n]"
>
> DEBUG [httpclient.wire.header] << "HTTP/1.1 200 OK[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 10:49:20
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
> x86 java/1.5.0_02[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Length: 44[\r][\n]"
> DEBUG [httpclient.wire.header] << "Last-Modified: Wed, 25 May 2005 12:56:31
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Accept-Ranges: bytes[\r][\n]"
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
RE: Unbuffered entity enclosing request can not be repeated
Posted by Tony Seebregts <to...@cibecs.com>.
Thanks Oleg, was afraid that might be the answer. Sounds like it's a bit of
a grey area in the HTTP spec.
While I'm asking questions - if I implement a custom SSL protocol handler
and register it as the handler for SSL the server sends back a '302 - Moved
temporarily' response which causes the HttpClient to generate a 'cannot
follow redirect' type error.
It works fine if I just use the standard SSL protocol handler - but the
EasySSLProtocolSocketFactory and StrictSSLProtocolSocketFactory throw the
exception.
Any ideas ? The wire log is below:
Regards
Tony
DEBUG [httpclient.wire.header] >> "GET /guest HTTP/1.1[\r][\n]"
DEBUG [httpclient.wire.header] >> "Authorization: Basic
YWdlbnR4OjAwNw==[\r][\n]"
DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
Commons-HttpClient/2.0.2[\r][\n]"
DEBUG [httpclient.wire.header] >> "Host: localhost:8443[\r][\n]"
DEBUG [httpclient.wire.header] >> "[\r][\n]"
DEBUG [httpclient.wire.header] << "HTTP/1.1 302 Moved Temporarily[\r][\n]"
DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 10:49:20
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
x86 java/1.5.0_02[\r][\n]"
DEBUG [httpclient.wire.header] << "Location:
https://localhost:8443/guest/[\r][\n]"
DEBUG [httpclient.wire.header] << "Transfer-Encoding: chunked[\r][\n]"
DEBUG [httpclient.wire.header] >> "GET /guest/ HTTP/1.1[\r][\n]"
DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
Commons-HttpClient/2.0.2[\r][\n]"
DEBUG [httpclient.wire.header] >> "Host: localhost:8443[\r][\n]"
DEBUG [httpclient.wire.header] >> "[\r][\n]"
DEBUG [httpclient.wire.header] << "HTTP/1.1 200 OK[\r][\n]"
DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 10:49:20
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
x86 java/1.5.0_02[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Length: 44[\r][\n]"
DEBUG [httpclient.wire.header] << "Last-Modified: Wed, 25 May 2005 12:56:31
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Accept-Ranges: bytes[\r][\n]"
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Unbuffered entity enclosing request can not be repeated
Posted by Oleg Kalnichevski <ol...@apache.org>.
Tony,
It does not make much sense, as this behavior totally defeats the
purpose of the expect-continue handshake, but it is not illegal from the
HTTP spec standpoint.
I am afraid your do not have that many options here
(1) Use preemptive authentication
(2) Buffer the request body
(3) Do a HTTP GET first against the target url, deal with the authentication,
if successful do HTTP POST with non-buffered request body
Hope this helps
Oleg
On Fri, Jun 10, 2005 at 08:33:23AM +0200, Tony Seebregts wrote:
> Hi Oleg,
>
> re. wire log. Duh ! Should have thought of that - here it is (with the
> writeRequestBody() calls):
>
> DEBUG [httpclient.wire.header] >> "POST /agent/put/qqq/www HTTP/1.1[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Content-Type:
> application/x-cibecs-fp[\r][\n]"
> DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
> Commons-HttpClient/2.0.2[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Host: 127.0.0.1:8080[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Transfer-Encoding: chunked[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Expect: 100-continue[\r][\n]"
> DEBUG [httpclient.wire.header] >> "[\r][\n]"
>
> DEBUG [httpclient.wire.header] << "HTTP/1.1 100 Continue[\r][\n]"
> DEBUG [com.cibecs.brs.core.net.http.RequestMethod] **** writeRequestBody()
> DEBUG [httpclient.wire.header] << "HTTP/1.1 401 Unauthorized[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 06:26:07
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
> x86 java/1.5.0_02[\r][\n]"
> DEBUG [httpclient.wire.header] << "WWW-Authenticate: basic
> realm="agent"[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Length: 1278[\r][\n]"
>
> DEBUG [httpclient.wire.header] >> "POST /agent/put/qqq/www HTTP/1.1[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Content-Type:
> application/x-cibecs-fp[\r][\n]"
> DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
> Commons-HttpClient/2.0.2[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Host: 127.0.0.1:8080[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Transfer-Encoding: chunked[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Expect: 100-continue[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Authorization: Basic
> YWdlbnR4OjAwNw==[\r][\n]"
> DEBUG [httpclient.wire.header] >> "[\r][\n]"
>
> DEBUG [httpclient.wire.header] << "HTTP/1.1 100 Continue[\r][\n]"
> DEBUG [com.cibecs.brs.core.net.http.RequestMethod] **** writeRequestBody()
> DEBUG [httpclient.wire.header] << "HTTP/1.1 200 OK[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 06:26:28
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
> x86 java/1.5.0_02[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Length: 237[\r][\n]"
>
> Hmmm ... the server is returning a '100 Continue' followed immediately by a
> '401 Unauthorized'. Is that correct ?
>
> Regards
>
> Tony
>
>
> -----Original Message-----
> From: Oleg Kalnichevski [mailto:olegk@apache.org]
> Sent: 9 June 2005 17:58
> To: 'HttpClient User Discussion'
> Subject: Re: Unbuffered entity enclosing request can not be repeated
>
> Tony,
>
> It is entirely possible that the target server does not support / does
> not honor the expect-continue handshake. If you post the wire log of the
> HTTP session, we'd be able to tell for sure
>
> Oleg
>
> On Thu, Jun 09, 2005 at 05:18:10PM +0200, Tony Seebregts wrote:
> > Hi Roland,
> >
> > Thanks for the suggestion - have just tried it though and I still get the
> > double writeRequestBody() call.
> >
> > Hmmm ... wonder if its not a web server issue perhaps.
> >
> > Regards
> >
> > Tony
> >
> >
> > -----Original Message-----
> > From: Roland Weber [mailto:ROLWEBER@de.ibm.com]
> > Sent: 9 June 2005 17:04
> > To: HttpClient User Discussion
> > Subject: Re: Unbuffered entity enclosing request can not be repeated
> >
> > Hello Tony,
> >
> > enable the expect-continue handshake. Then the client
> > gets the "authentication required" response before it
> > tries to send the body.
> >
> > Sorry, I don't have the method name at hand.
> >
> > hope that helps anyway,
> > Roland
> >
> >
> >
> >
> > "Tony Seebregts" <to...@cibecs.com>
> > 09.06.2005 16:45
> > Please respond to
> > "HttpClient User Discussion"
> >
> >
> > To
> > <ht...@jakarta.apache.org>
> > cc
> >
> > Subject
> > Unbuffered entity enclosing request can not be repeated
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > I'm using the HttpClient to POST a request to the server with the
> > Content-Length set to CONTENT_LENGTH_CHUNKED.
> >
> >
> >
> > It works fine with pre-emptive BASIC authentication but fails with an
> > "Unbuffered entity enclosing request
> > can not be repeated" with anything else.
> >
> >
> >
> > Tracing the request it seems that the HttpClient attempts to read the
> > request body twice - at a guess before the authentication
> >
> > challenge and then again when authenticated.
> >
> >
> >
> > The workaround I have for now is to 'ignore' the first request (actually
> > send an empty body) and then send the real data
> >
> > through on the second writeRequestBody() call.
> >
> >
> >
> > This seems more than a bit flaky - does anybody have a better solution ?
> >
> >
> >
> > Regards
> >
> >
> >
> > Tony Seebregts
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Athentication/Expect-Continue - Follow-Up
Posted by Oleg Kalnichevski <ol...@apache.org>.
Tony,
Here's my take for what it is worth
Section 8.2.3 of RFC2616 "Use of the 100 (Continue) Status" clearly
states the following:
...
The purpose of the 100 (Continue) status (see section 10.1.1) is to
allow a client that is sending a request message with a request body
to determine if the origin server is willing to accept the request
(based on the request headers) before the client sends the request
body. In some cases, it might either be inappropriate or highly
inefficient for the client to send the body if the server will reject
the message without looking at the body.
...
While not entirely restricted to enforcing security constraints, as
correctly asserted by Jetty's developers, in my opinion the chief reason
for the origin server not "willing to accept the request (based on the
request headers)" is (1) violation of the request format, (2) invalid
authentication or (3) insufficient access permissions on the part of the
client
The interpretation of the 100-continue handshake by the Jetty's
developers while not directly contradictory to the formal letter of the
HTTP spec, IMHO fails to adequately address the fact that in many
real-life scenarios HTTP requests are rejected solely based on security
considerations
RFC 2617
1.2 Access Authentication Framework
...
If the origin server does not wish to accept the credentials sent
with a request, it SHOULD return a 401 (Unauthorized) response. The
response MUST include a WWW-Authenticate header field containing at
least one (possibly new) challenge applicable to the requested
resource. If a proxy does not accept the credentials sent with a
request, it SHOULD return a 407 (Proxy Authentication Required). The
response MUST include a Proxy-Authenticate header field containing a
(possibly new) challenge applicable to the proxy for the requested
resource.
...
Overall, Jetty's implementation of the 100-continue handshake in its
present form simply makes Jetty less useful. Plain and simple. It us up
to Jetty's folks to choose either to ignore this fact or deal with the
issue
Oleg
Wed, Jun 22, 2005 at 09:09:46AM +0200, Tony Seebregts wrote:
> Hi Oleg/Roland,
>
> FYI, I've posted the reply from the Jetty support list about the
> Authentication/Expect-Continue problem (from about a week back). Seems like
> its an area open to interpretation.
>
> > | In Jetty at least the connection is not made between the application
> > | security constraints and the need to send (or not) a 100-continue.
> >
> > Per the specification, a 100-continue response is an:
> >
> > ".../interim response/ [which] is used to inform the client that the
> > /initial part of the request/ has been received and *has /not yet/
> > been rejected by the server*." -- HTTP 1.1 Spec., '10.1.1. 100 Continue'
> >
> > Obviously, a 100-continue response does not indicate that the final
> > request will not be rejected but only that the request in its initial
> > state is "so far OK". This has absolutely nothing to do with whether the
> > URI itself requires authentication for the /final request/.
> >
> > "....The server MUST send a /final response/ /after the request has been
> > completed/." -- supra.
> > Note that the specification states only that a "final response" is to be
> > sent after the full request is sent. It says nothing about whether any
> > other interim responses can be sent along with the 100 response, nor does
> > it indicate that a 100 response must be sent alone.
>
> Would be interested to hear your comments/interpretation. The Jetty
> developers are posting it to the RFC EG for clarification in the meantime
> though.
>
> Regards
>
> Tony Seebregts
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
RE: Unbuffered entity enclosing request can not be repeated
Posted by Tony Seebregts <to...@cibecs.com>.
Hi Roland,
Yeah, that's what I thought. I raised the issue with the Jetty developers
but it sounds like the behaviour is embedded fairly deeply in the
architecture.
Guess I'll have to live with. Thanks for the suggestions though.
Regards
Tony
-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com]
Sent: 10 June 2005 15:28
To: HttpClient User Discussion
Subject: RE: Unbuffered entity enclosing request can not be repeated
Hello Tony,
> DEBUG [httpclient.wire.header] << "HTTP/1.1 100 Continue[\r][\n]"
> DEBUG [com.cibecs.brs.core.net.http.RequestMethod] ****
writeRequestBody()
> DEBUG [httpclient.wire.header] << "HTTP/1.1 401 Unauthorized[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 06:26:07
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows
XP/5.1
> x86 java/1.5.0_02[\r][\n]"
> DEBUG [httpclient.wire.header] << "WWW-Authenticate: basic
> realm="agent"[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
>
> Hmmm ... the server is returning a '100 Continue' followed immediately
by a
> '401 Unauthorized'. Is that correct ?
It certainly isn't what the server is supposed to do.
Sending a 100-continue reply even though authentication
is required beats the whole purpose of the handshake.
Maybe the Jetty guys know more about this?
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
RE: Athentication/Expect-Continue - Follow-Up
Posted by Tony Seebregts <to...@cibecs.com>.
Hi Oleg/Roland,
Thanks very much for the comments - was reassured to see my thoughts were
pretty much in line with yours. I'll let you know what comes out of the RFC
discussion.
Regards
Tony
-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com]
Sent: 22 June 2005 10:28
To: HttpClient User Discussion
Subject: Re: Athentication/Expect-Continue - Follow-Up
Hello Tony,
thanks for keeping us up to date. My comment is the same as before:
technically, the spec is implemented correctly, but the purpose of
the 100-continue handshake is not achieved.
RFC 2616 [HTTP/1.1], section 8.2.3:
> The purpose of the 100 (Continue) status (see section 10.1.1) is to
> allow a client that is sending a request message with a request body
> to determine if the origin server is willing to accept the request
> (based on the request headers) before the client sends the request
> body. In some cases, it might either be inappropriate or highly
> inefficient for the client to send the body if the server will reject
> the message without looking at the body.
So if the authentication requirement does not depend on the contents
of the request body, the server SHOULD (but does not have to) send
the "auth required" response instead of a 100-continue. And in most
cases, access control is handled based on the URI, which is part of
the message header.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Athentication/Expect-Continue - Follow-Up
Posted by Roland Weber <RO...@de.ibm.com>.
Hello Tony,
thanks for keeping us up to date. My comment is the same as before:
technically, the spec is implemented correctly, but the purpose of
the 100-continue handshake is not achieved.
RFC 2616 [HTTP/1.1], section 8.2.3:
> The purpose of the 100 (Continue) status (see section 10.1.1) is to
> allow a client that is sending a request message with a request body
> to determine if the origin server is willing to accept the request
> (based on the request headers) before the client sends the request
> body. In some cases, it might either be inappropriate or highly
> inefficient for the client to send the body if the server will reject
> the message without looking at the body.
So if the authentication requirement does not depend on the contents
of the request body, the server SHOULD (but does not have to) send
the "auth required" response instead of a 100-continue. And in most
cases, access control is handled based on the URI, which is part of
the message header.
cheers,
Roland
"Tony Seebregts" <to...@cibecs.com>
22.06.2005 09:09
Please respond to
"HttpClient User Discussion"
To
"'HttpClient User Discussion'" <ht...@jakarta.apache.org>
cc
Subject
Athentication/Expect-Continue - Follow-Up
Hi Oleg/Roland,
FYI, I've posted the reply from the Jetty support list about the
Authentication/Expect-Continue problem (from about a week back). Seems
like
its an area open to interpretation.
> | In Jetty at least the connection is not made between the application
> | security constraints and the need to send (or not) a 100-continue.
>
> Per the specification, a 100-continue response is an:
>
> ".../interim response/ [which] is used to inform the client that the
> /initial part of the request/ has been received and *has /not yet/
> been rejected by the server*." -- HTTP 1.1 Spec., '10.1.1. 100 Continue'
>
> Obviously, a 100-continue response does not indicate that the final
> request will not be rejected but only that the request in its initial
> state is "so far OK". This has absolutely nothing to do with whether
the
> URI itself requires authentication for the /final request/.
>
> "....The server MUST send a /final response/ /after the request has been
> completed/." -- supra.
> Note that the specification states only that a "final response" is to be
> sent after the full request is sent. It says nothing about whether any
> other interim responses can be sent along with the 100 response, nor
does
> it indicate that a 100 response must be sent alone.
Would be interested to hear your comments/interpretation. The Jetty
developers are posting it to the RFC EG for clarification in the meantime
though.
Regards
Tony Seebregts
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Athentication/Expect-Continue - Follow-Up
Posted by Tony Seebregts <to...@cibecs.com>.
Hi Oleg/Roland,
FYI, I've posted the reply from the Jetty support list about the
Authentication/Expect-Continue problem (from about a week back). Seems like
its an area open to interpretation.
> | In Jetty at least the connection is not made between the application
> | security constraints and the need to send (or not) a 100-continue.
>
> Per the specification, a 100-continue response is an:
>
> ".../interim response/ [which] is used to inform the client that the
> /initial part of the request/ has been received and *has /not yet/
> been rejected by the server*." -- HTTP 1.1 Spec., '10.1.1. 100 Continue'
>
> Obviously, a 100-continue response does not indicate that the final
> request will not be rejected but only that the request in its initial
> state is "so far OK". This has absolutely nothing to do with whether the
> URI itself requires authentication for the /final request/.
>
> "....The server MUST send a /final response/ /after the request has been
> completed/." -- supra.
> Note that the specification states only that a "final response" is to be
> sent after the full request is sent. It says nothing about whether any
> other interim responses can be sent along with the 100 response, nor does
> it indicate that a 100 response must be sent alone.
Would be interested to hear your comments/interpretation. The Jetty
developers are posting it to the RFC EG for clarification in the meantime
though.
Regards
Tony Seebregts
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
RE: Unbuffered entity enclosing request can not be repeated
Posted by Roland Weber <RO...@de.ibm.com>.
Hello Tony,
> DEBUG [httpclient.wire.header] << "HTTP/1.1 100 Continue[\r][\n]"
> DEBUG [com.cibecs.brs.core.net.http.RequestMethod] ****
writeRequestBody()
> DEBUG [httpclient.wire.header] << "HTTP/1.1 401 Unauthorized[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 06:26:07
> GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows
XP/5.1
> x86 java/1.5.0_02[\r][\n]"
> DEBUG [httpclient.wire.header] << "WWW-Authenticate: basic
> realm="agent"[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
>
> Hmmm ... the server is returning a '100 Continue' followed immediately
by a
> '401 Unauthorized'. Is that correct ?
It certainly isn't what the server is supposed to do.
Sending a 100-continue reply even though authentication
is required beats the whole purpose of the handshake.
Maybe the Jetty guys know more about this?
cheers,
Roland
RE: Unbuffered entity enclosing request can not be repeated
Posted by Tony Seebregts <to...@cibecs.com>.
Hi Oleg,
re. wire log. Duh ! Should have thought of that - here it is (with the
writeRequestBody() calls):
DEBUG [httpclient.wire.header] >> "POST /agent/put/qqq/www HTTP/1.1[\r][\n]"
DEBUG [httpclient.wire.header] >> "Content-Type:
application/x-cibecs-fp[\r][\n]"
DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
Commons-HttpClient/2.0.2[\r][\n]"
DEBUG [httpclient.wire.header] >> "Host: 127.0.0.1:8080[\r][\n]"
DEBUG [httpclient.wire.header] >> "Transfer-Encoding: chunked[\r][\n]"
DEBUG [httpclient.wire.header] >> "Expect: 100-continue[\r][\n]"
DEBUG [httpclient.wire.header] >> "[\r][\n]"
DEBUG [httpclient.wire.header] << "HTTP/1.1 100 Continue[\r][\n]"
DEBUG [com.cibecs.brs.core.net.http.RequestMethod] **** writeRequestBody()
DEBUG [httpclient.wire.header] << "HTTP/1.1 401 Unauthorized[\r][\n]"
DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 06:26:07
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
x86 java/1.5.0_02[\r][\n]"
DEBUG [httpclient.wire.header] << "WWW-Authenticate: basic
realm="agent"[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Length: 1278[\r][\n]"
DEBUG [httpclient.wire.header] >> "POST /agent/put/qqq/www HTTP/1.1[\r][\n]"
DEBUG [httpclient.wire.header] >> "Content-Type:
application/x-cibecs-fp[\r][\n]"
DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta
Commons-HttpClient/2.0.2[\r][\n]"
DEBUG [httpclient.wire.header] >> "Host: 127.0.0.1:8080[\r][\n]"
DEBUG [httpclient.wire.header] >> "Transfer-Encoding: chunked[\r][\n]"
DEBUG [httpclient.wire.header] >> "Expect: 100-continue[\r][\n]"
DEBUG [httpclient.wire.header] >> "Authorization: Basic
YWdlbnR4OjAwNw==[\r][\n]"
DEBUG [httpclient.wire.header] >> "[\r][\n]"
DEBUG [httpclient.wire.header] << "HTTP/1.1 100 Continue[\r][\n]"
DEBUG [com.cibecs.brs.core.net.http.RequestMethod] **** writeRequestBody()
DEBUG [httpclient.wire.header] << "HTTP/1.1 200 OK[\r][\n]"
DEBUG [httpclient.wire.header] << "Date: Fri, 10 Jun 2005 06:26:28
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Server: Jetty/5.1.3rc3 (Windows XP/5.1
x86 java/1.5.0_02[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Length: 237[\r][\n]"
Hmmm ... the server is returning a '100 Continue' followed immediately by a
'401 Unauthorized'. Is that correct ?
Regards
Tony
-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org]
Sent: 9 June 2005 17:58
To: 'HttpClient User Discussion'
Subject: Re: Unbuffered entity enclosing request can not be repeated
Tony,
It is entirely possible that the target server does not support / does
not honor the expect-continue handshake. If you post the wire log of the
HTTP session, we'd be able to tell for sure
Oleg
On Thu, Jun 09, 2005 at 05:18:10PM +0200, Tony Seebregts wrote:
> Hi Roland,
>
> Thanks for the suggestion - have just tried it though and I still get the
> double writeRequestBody() call.
>
> Hmmm ... wonder if its not a web server issue perhaps.
>
> Regards
>
> Tony
>
>
> -----Original Message-----
> From: Roland Weber [mailto:ROLWEBER@de.ibm.com]
> Sent: 9 June 2005 17:04
> To: HttpClient User Discussion
> Subject: Re: Unbuffered entity enclosing request can not be repeated
>
> Hello Tony,
>
> enable the expect-continue handshake. Then the client
> gets the "authentication required" response before it
> tries to send the body.
>
> Sorry, I don't have the method name at hand.
>
> hope that helps anyway,
> Roland
>
>
>
>
> "Tony Seebregts" <to...@cibecs.com>
> 09.06.2005 16:45
> Please respond to
> "HttpClient User Discussion"
>
>
> To
> <ht...@jakarta.apache.org>
> cc
>
> Subject
> Unbuffered entity enclosing request can not be repeated
>
>
>
>
>
>
> Hi,
>
>
>
> I'm using the HttpClient to POST a request to the server with the
> Content-Length set to CONTENT_LENGTH_CHUNKED.
>
>
>
> It works fine with pre-emptive BASIC authentication but fails with an
> "Unbuffered entity enclosing request
> can not be repeated" with anything else.
>
>
>
> Tracing the request it seems that the HttpClient attempts to read the
> request body twice - at a guess before the authentication
>
> challenge and then again when authenticated.
>
>
>
> The workaround I have for now is to 'ignore' the first request (actually
> send an empty body) and then send the real data
>
> through on the second writeRequestBody() call.
>
>
>
> This seems more than a bit flaky - does anybody have a better solution ?
>
>
>
> Regards
>
>
>
> Tony Seebregts
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Unbuffered entity enclosing request can not be repeated
Posted by Oleg Kalnichevski <ol...@apache.org>.
Tony,
It is entirely possible that the target server does not support / does
not honor the expect-continue handshake. If you post the wire log of the
HTTP session, we'd be able to tell for sure
Oleg
On Thu, Jun 09, 2005 at 05:18:10PM +0200, Tony Seebregts wrote:
> Hi Roland,
>
> Thanks for the suggestion - have just tried it though and I still get the
> double writeRequestBody() call.
>
> Hmmm ... wonder if its not a web server issue perhaps.
>
> Regards
>
> Tony
>
>
> -----Original Message-----
> From: Roland Weber [mailto:ROLWEBER@de.ibm.com]
> Sent: 9 June 2005 17:04
> To: HttpClient User Discussion
> Subject: Re: Unbuffered entity enclosing request can not be repeated
>
> Hello Tony,
>
> enable the expect-continue handshake. Then the client
> gets the "authentication required" response before it
> tries to send the body.
>
> Sorry, I don't have the method name at hand.
>
> hope that helps anyway,
> Roland
>
>
>
>
> "Tony Seebregts" <to...@cibecs.com>
> 09.06.2005 16:45
> Please respond to
> "HttpClient User Discussion"
>
>
> To
> <ht...@jakarta.apache.org>
> cc
>
> Subject
> Unbuffered entity enclosing request can not be repeated
>
>
>
>
>
>
> Hi,
>
>
>
> I'm using the HttpClient to POST a request to the server with the
> Content-Length set to CONTENT_LENGTH_CHUNKED.
>
>
>
> It works fine with pre-emptive BASIC authentication but fails with an
> "Unbuffered entity enclosing request
> can not be repeated" with anything else.
>
>
>
> Tracing the request it seems that the HttpClient attempts to read the
> request body twice - at a guess before the authentication
>
> challenge and then again when authenticated.
>
>
>
> The workaround I have for now is to 'ignore' the first request (actually
> send an empty body) and then send the real data
>
> through on the second writeRequestBody() call.
>
>
>
> This seems more than a bit flaky - does anybody have a better solution ?
>
>
>
> Regards
>
>
>
> Tony Seebregts
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
RE: Unbuffered entity enclosing request can not be repeated
Posted by Tony Seebregts <to...@cibecs.com>.
Hi Roland,
Thanks for the suggestion - have just tried it though and I still get the
double writeRequestBody() call.
Hmmm ... wonder if its not a web server issue perhaps.
Regards
Tony
-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com]
Sent: 9 June 2005 17:04
To: HttpClient User Discussion
Subject: Re: Unbuffered entity enclosing request can not be repeated
Hello Tony,
enable the expect-continue handshake. Then the client
gets the "authentication required" response before it
tries to send the body.
Sorry, I don't have the method name at hand.
hope that helps anyway,
Roland
"Tony Seebregts" <to...@cibecs.com>
09.06.2005 16:45
Please respond to
"HttpClient User Discussion"
To
<ht...@jakarta.apache.org>
cc
Subject
Unbuffered entity enclosing request can not be repeated
Hi,
I'm using the HttpClient to POST a request to the server with the
Content-Length set to CONTENT_LENGTH_CHUNKED.
It works fine with pre-emptive BASIC authentication but fails with an
"Unbuffered entity enclosing request
can not be repeated" with anything else.
Tracing the request it seems that the HttpClient attempts to read the
request body twice - at a guess before the authentication
challenge and then again when authenticated.
The workaround I have for now is to 'ignore' the first request (actually
send an empty body) and then send the real data
through on the second writeRequestBody() call.
This seems more than a bit flaky - does anybody have a better solution ?
Regards
Tony Seebregts
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Unbuffered entity enclosing request can not be repeated
Posted by Roland Weber <RO...@de.ibm.com>.
Hello Tony,
enable the expect-continue handshake. Then the client
gets the "authentication required" response before it
tries to send the body.
Sorry, I don't have the method name at hand.
hope that helps anyway,
Roland
"Tony Seebregts" <to...@cibecs.com>
09.06.2005 16:45
Please respond to
"HttpClient User Discussion"
To
<ht...@jakarta.apache.org>
cc
Subject
Unbuffered entity enclosing request can not be repeated
Hi,
I'm using the HttpClient to POST a request to the server with the
Content-Length set to CONTENT_LENGTH_CHUNKED.
It works fine with pre-emptive BASIC authentication but fails with an
"Unbuffered entity enclosing request
can not be repeated" with anything else.
Tracing the request it seems that the HttpClient attempts to read the
request body twice - at a guess before the authentication
challenge and then again when authenticated.
The workaround I have for now is to 'ignore' the first request (actually
send an empty body) and then send the real data
through on the second writeRequestBody() call.
This seems more than a bit flaky - does anybody have a better solution ?
Regards
Tony Seebregts