hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Johnson <e...@tibco.com>
Subject Re: How to send byte-array data in a multipart post?
Date Fri, 28 Feb 2003 19:39:50 GMT
James,

The way I built my mental model, a "multipart/form-data" post consists 
of two distinct kinds of parts, "file" parts, and "string" parts.  The 
fundamental distinction is one of "binary" versus "text" data, although 
the distinction is, as always, somewhat arbitrary.  I think the 
nomenclature comes from staring at too many web-browsers, where the 
<input type="file" /> tag might lead one to call that kind of part a 
"file" part, rather than something like a "binary" or "raw bytes" part, 
and <input type="text" > or <input type="hidden"> which both send 
strings, ends up getting called a "StringPart".

For the "raw" part (aka "file"), you need to indicate a data source.  It 
isn't quite sufficient to pass an "InputStream", as sometimes HttpClient 
needs to retry sending your request, in which case it may need to 
restart the reading of your original data.

Hope that helps to clarify.

-Eric.


Couball, James wrote:

>This seems non-intuitive... or do I just not understand the
>reason/responsibility for FilePart and StringPart?  The documentation
>doesn't shed any light here.
>
>Could someone help me to understand?
>
>Sincerely,
>James.
>
>-----Original Message-----
>From: Michael Becke [mailto:becke@u.washington.edu] 
>Sent: Friday, February 28, 2003 4:37 AM
>To: Commons HttpClient Project
>Subject: Re: How to send byte-array data in a multipart post?
>
>You want to use the FilePart.  It accepts a PartSource in the 
>constructor, which ByteArrayPartSource implements.
>
>Mike
>
>On Friday, February 28, 2003, at 07:04 AM, 
>olaf.hahnl@notes.uni-paderborn.de wrote:
>
>  
>
>>I like to send data already in memory as a byte-array in a multipart 
>>post.
>>In the package "org.apache.commons.httpclient.methods.multipart" I saw 
>>the
>>class "ByteArrayPartSource" but no corresponding "ByteArrayPart" 
>>class, to
>>use in MultipartPostMethod.addPart(Part part). Is there a special 
>>reason or
>>problem why this class is not provided in the core.
>>
>>Thank you for your help,
>>Olaf
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: 
>>commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: 
>>commons-httpclient-dev-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail:
>commons-httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail:
>commons-httpclient-dev-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
>  
>


Mime
View raw message