pocoproject/poco — pull request #344 by RangelReale (2013-12-04 20:28:09+00:00)
Title: HTMLForm Content-Length calculation

To post multipart/form-data to squid < 3.2, it is necessary to use HTTP 1.0, but HTTP 1.0 requires the Content-Length header to be set for this type of post.

This patch adds a "calculateContentLength" method to HTMLForm, that returns the number of bytes if possible.

As it is not guaranteed that streams can be seeked, PartSource sizes cannot be returned from the stream, so a new getContentLength method was added to PartSource.

Also support for adding arbitrary amount of chars in CountintStream was added, so that the Part size can be added without really writing bytes.

This is tested to be compatible with squid 2.7 and up, using HTTP 1.0.