[prev in list] [next in list] [prev in thread] [next in thread]
List: httpclient-users
Subject: Re: unable to read mime boundary headers
From: Richard Jones <richard () symplectic ! co ! uk>
Date: 2009-06-08 14:36:34
Message-ID: 4A2D21F2.5050505 () symplectic ! co ! uk
[Download RAW message or body]
Hi Pete,
> The boundary is declared in the header of the "original" HTTP request. All you \
> have below is a single mime body part.
> The original request would have had a content-type header something like this:
> content-type: multipart/report; report-type=disposition-notification; \
> boundary="----=_Part_6_17038270.1191609292302"
> That is, if it were valid...
>
> You need to get the boundary from the header of the original HTTP request.
>
I only included the part of the http request which contained the mime
boundary and subsequent headers that I was looking at; it is part of a
much larger http request containing full headers, and a number of other
mime parts. Consequent to that, the mime boundary itself is extracted
from the main http headers, and parsed just fine, and I can access all
of the content of the mime parts, and the content type from those
headers that I included. What doesn't work is doing a getHeaders
request on the DiskFileItem; it always returns null.
Cheers,
Richard
>
> ...Pete
> Starbucks Coffee Co.
> 2401 Utah Ave S.
> Seattle, WA. 98134
> (work)206-318-5933
> (cell)206-226-4552
>
> After hours emergency pager:
> 206-314-2054 or page-pkeyes@starbucks.com
>
>
> -----Original Message-----
> From: Richard Jones [mailto:richard@symplectic.co.uk]
> Sent: Monday, June 08, 2009 3:38 AM
> To: httpclient-users@hc.apache.org
> Subject: unable to read mime boundary headers
>
> Hi Folks,
>
> I'm trying to read headers from a mime boudary, with no success. Can
> anyone tell me what I'm doing wrong here (with version 3.1 of http client):
>
> FileItemFactory factory = new DiskFileItemFactory();
> ServletFileUpload upload = new ServletFileUpload(factory);
> List<DiskFileItem> items = upload.parseRequest(request);
>
> for (DiskFileItem item : items)
> {
> String ct = item.getContentType();
> FileItemHeaders hed = item.getHeaders();
> String cd = hed.getHeader("Content-Disposition");
> }
>
> At this point, hed is always null (so the final line throws an NPE).
> Perplexingly, though, the content type variable contains the content
> type. The http request is definitely valid, and contains a mime
> boundary thus:
>
> --NlWHLgeBI76ZytSdNwyoMKnfTjSG8ocZuIh
> Content-Disposition: form-data; name="atom"; filename="atom.xml"
> Content-Type: text/xml; charset=UTF-8
> Content-Transfer-Encoding: binary
>
> Any suggestions? Something wrong with the DiskFileItem implementation?
> A mis-use of getHeaders?
>
> Cheers,
>
> Richard
>
>
--
Richard Jones
Head Repository Systems Architect, Symplectic Limited
e: richard@symplectic.co.uk
t: 0845 026 4755
t: +44 (0)207 7334036
w: http://www.symplectic.co.uk/
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic