commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul C. Bryan" <>
Subject [HttpClient] Bug 5018 PATCH
Date Wed, 28 Nov 2001 21:43:47 GMT

Chunked transfer encoding not isolated from application.


Chunked transfer encoding is not being supported transparently by the 
HttpMethodBase object, causing chunk data to be embedded in response 
body data and forcing the application to handle the HTTP/1.1 
implementation of chunked transfer encoding.

The included patch now properly parses chunk data as per HTTP/1.1 and 
provides body content consistently, regardless of whether chunked 
transfer encoding was used by the server or not. This relieves the 
application from the requirement of implementing HTTP/1.1.

Patch Notes:

HTTP/1.1 specifies optional footer fields that are supplied after the 
end of the chunked data body. These are parsed, but added as "header" 
fields because I didn't want to change the HttpMethod interface. The 
result is that footer fields such as signatures must be retrieved as 
headers. The downside to this approach is there is no way to distinguish 
  between a header field and a footer field when interrogating the 

I've defined a constant SIZE_buf to use as a buffer size for allocated 
copy buffers. I've only used it in my patch (because it is referred to 
more than once in the method), but propose that it be used by any 
methods that perform copy operations with the allocation of a buffer. 

Because a ResponseInputStream is used to read the body, the response 
footers cannot be retrived using the conn.readLine() method. Instead, 
the ResponseInputStream.readLine method must be used. For this reason, 
response footers are read after the body in the readResponseBody method.

I'm not sure why only get request method is supporting writing content 
to disk. I believe the useDisk functionality should be moved to 
HttpMethodBase. I was tempted to do so, but didn't want to jeopardize 
the acceptance of this patch. If someone gives me the go ahead, I am 
willing to move useDisk into HttpMethodBase.

GetMethod.readResponseBody(HttpState, HttpConnection) duplicated much of 
HttpMethodBase.readResponseBody(HttpState, HttpConnection) 
functionality. I moved this into a new common 
readResponseBody(ResponseInputStream, OutputStream) that is shared by 
HttpMethodBase and GetMethod. If useDisk moves into HttpMethodBase, 
there should be no longer be a need for this separate method.

The included patches have been extensively tested against a WebLogic 6.1 
SP1 server, which makes use of chunked transfer encoding when content 
length is not known ahead of time.

I've gone out of my way to keep the style of this patch consistent with 
the existing source code. I'm curious how much liberty I can take in the 
future when it comes to formatting.

Yours truly,

Paul C. Bryan

View raw message