Issue Details (XML | Word | Printable)

Key: HTTPCLIENT-600
Type: Improvement Improvement
Status: Closed Closed
Resolution: Invalid
Priority: Major Major
Assignee: Unassigned
Reporter: Denis Valdenaire
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
HttpComponents HttpClient

Http Client does not fix incorrect content-lenght headers

Created: 15/Sep/06 10:34 AM   Updated: 22/Apr/07 07:11 AM
Return to search
Component/s: HttpClient
Affects Version/s: 3.1 Alpha 1
Fix Version/s: None

Time Tracking:
Not Specified

Environment: All

Resolution Date: 15/Sep/06 01:16 PM


 Description  « Hide
I discovered that the method

addContentLengthRequestHeader (found in file methods/MultipartPostMethod.java) doesn't "fix" the content-lenght when this one is incorrect. It adds one if getRequestHeader("Content-Lenght") is null, but it should also verify that the content-lenght is correct.

I suggest something like :

long len = getRequestContentLength();
if (getRequestHeader("Content-Length") == null || getRequestHeader("Content-Length") != len) {
            setRequestHeader("Content-Length", String.valueOf(len));
}

Sending an incorrect Content-Length blocks the server if the string sent is smaller than announced : waiting for more, and finally reset the connection. If it's too big, you lose data.

I've seen this problem in a reverse proxy program (with httpclient communicating with the real servers) when the client send urlencoded data and this data is modified (partly urldecoded) but not the content-lenght.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.