You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "S. Aden" <ad...@gmail.com> on 2006/01/18 20:29:13 UTC

Why is Part Content-Length Missing?

I am trying to post several files to a server using HTTPClient 3.0 and
would like to include the length of each file part in the part header.
Looking at the HTTPClient 3.0 code and I see that for each part
Content-Disposition, Content-Type, and Content-Transfer-Encoding are
sent in the header but Content-Length is not. I guess my question is,
is there a good reason why it was left out and would a patch that adds
Content-Length to each part header be accepted for future HTTPClient
release?

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Why is Part Content-Length Missing?

Posted by Oleg Kalnichevski <ol...@apache.org>.
S. Aden wrote:
> Thanks for the quick response. RFC 1867 stats the following which
> leads me to believe that while it is not mandatory that Content-Length
> be present it is optional and recommended. Perhaps I am missing
> something?
> 
> "The HTTP protocol may require a content-length for the overall
> transmission. Even if it were not to do so, HTTP clients are
> encouraged to supply content-length for overall file input so that a
> busy server could detect if the proposed file data is too large to be
> processed reasonably and just return an error code and close the
> connection without waiting to process all of the incoming data.  Some
> current implementations of CGI require a content-length in all POST
> transactions."
> 

This paragraph refers to the content delimitation of the HTTP entity 
enclosing requests (the content length of the entire HTTP packet). The 
mulpart/form-data encoding has nothing to do with HTTP transport. The 
relevant specs are

RFC 2388 (Returning Values from Forms:  multipart/form-data)
http://rfc.sunsite.dk/rfc/rfc2388.html

RFC 1521 (MIME (Multipurpose Internet Mail Extensions) Part One: 
Mechanisms for Specifying and Describing the Format of Internet Message 
Bodies)
http://rfc.dotsrc.org/rfc/rfc1521.html

Hope this helps

Oleg

> On 1/18/06, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> 
>>Because the Content-Length header is not required by the MIME spec
>>
>>Hope this explains it
>>
>>Oleg
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Why is Part Content-Length Missing?

Posted by "S. Aden" <ad...@gmail.com>.
Thanks for the quick response. RFC 1867 stats the following which
leads me to believe that while it is not mandatory that Content-Length
be present it is optional and recommended. Perhaps I am missing
something?

"The HTTP protocol may require a content-length for the overall
transmission. Even if it were not to do so, HTTP clients are
encouraged to supply content-length for overall file input so that a
busy server could detect if the proposed file data is too large to be
processed reasonably and just return an error code and close the
connection without waiting to process all of the incoming data.  Some
current implementations of CGI require a content-length in all POST
transactions."

On 1/18/06, Oleg Kalnichevski <ol...@apache.org> wrote:

> Because the Content-Length header is not required by the MIME spec
>
> Hope this explains it
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Why is Part Content-Length Missing?

Posted by Oleg Kalnichevski <ol...@apache.org>.
S. Aden wrote:
> I am trying to post several files to a server using HTTPClient 3.0 and
> would like to include the length of each file part in the part header.
> Looking at the HTTPClient 3.0 code and I see that for each part
> Content-Disposition, Content-Type, and Content-Transfer-Encoding are
> sent in the header but Content-Length is not. I guess my question is,
> is there a good reason why it was left out and would a patch that adds
> Content-Length to each part header be accepted for future HTTPClient
> release?
> 

Because the Content-Length header is not required by the MIME spec

Hope this explains it

Oleg


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Why is Part Content-Length Missing?

Posted by Ortwin Glück <od...@odi.ch>.
Aden,

It's correct that multipart MIME is unsafe in that respect. On the other 
hand it allows to stream data whose size is not known beforehand. 
Unfortunately HttpClient's multipart implementation does not allow 
adding of custom headers easily. You may exchange it with a different 
implementation however.

Ortwin Glück

S. Aden wrote:
> My problem is that while it is highly unlikely that the boundary
> string will appear in the content itself there is no guarantee that it
> won't unless you Base64 encode the content you're sending (dash will
> never appear in Base64 encoded content). What I really wanted to do is
> to add another level of assurance if I choose not to encode the
> content by adding a Content-Length header attribute for each part so
> that I am not relying on only the boundary string to tell me when the
> next part begins.
> 
> -Aden

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Why is Part Content-Length Missing?

Posted by "S. Aden" <ad...@gmail.com>.
My problem is that while it is highly unlikely that the boundary
string will appear in the content itself there is no guarantee that it
won't unless you Base64 encode the content you're sending (dash will
never appear in Base64 encoded content). What I really wanted to do is
to add another level of assurance if I choose not to encode the
content by adding a Content-Length header attribute for each part so
that I am not relying on only the boundary string to tell me when the
next part begins.

-Aden

On 19 Jan 2006 09:39:52 +0100, Guillaume Cottenceau <gc...@mnc.ch> wrote:
> "S. Aden" <aden.list 'at' gmail.com> writes:
>
> > I am trying to post several files to a server using HTTPClient 3.0 and
> > would like to include the length of each file part in the part header.
>
> (after reading Oleg responses) Maybe it would help us if you
> would explain what problem you are trying to solve with this
> approach?
>
> --
> Guillaume Cottenceau
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: Why is Part Content-Length Missing?

Posted by Guillaume Cottenceau <gc...@mnc.ch>.
"S. Aden" <aden.list 'at' gmail.com> writes:

> I am trying to post several files to a server using HTTPClient 3.0 and
> would like to include the length of each file part in the part header.

(after reading Oleg responses) Maybe it would help us if you
would explain what problem you are trying to solve with this
approach?

-- 
Guillaume Cottenceau

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org