There appears to have been no actvity on this topic since 2009 -- but the
question is STILL important to me -- how do you retrieve an attached file,
such as the one referenced here:

HTTP/1.1 200 OK [Date: Wed, 28 Dec 2011 19:51:29 GMT, Server: XXX XX Web,
Content-Length: 0, Content-Disposition:
attachment;filename="contracts_and_schedules.xml";, Keep-Alive: timeout=5,
max=98, Connection: Keep-Alive, Content-Type: text]

??

Note that the Content-Length is 0.  I am converting from standard
javax.net.HttpURLConnection use to HttpClient 4 -- my original program just
opened an InputStream on the connection and did .read().  But since the
Content is empty, getEntity().getContent() returns nothing.

I know that this isn't addressed by the HTTP standard - I'm dealing with a
VERY non-standard service, but I am surprised that there is apparently no
way to address this using the HttpCLient.

Any suggestions would be appreciated.

respects,

d.


Sam Berlin wrote:
> 
> Your best bet to figure out what your browser is sending/receiving is
> using
> a tool like Wireshark.
> 
> Sam
> 
> On Wed, Sep 9, 2009 at 8:35 AM, caymanag <[email protected]> wrote:
> 
>>
>> Ok, I agree that there is apparently no content to read.   When a web
>> browser
>> sees the Content-disposition: attachment; filename="myfile.csv", it knows
>> to
>> pop up a dialog box and/or save the file to the file system.   What do I
>> need to do in a client application to read an attachment, once I see this
>> same header?   Do I issue another GET and somehow append the filename?
>>
>>
>> olegk wrote:
>> >
>> > On Wed, Sep 09, 2009 at 04:45:52AM -0700, caymanag wrote:
>> >>
>> >> The log is the (DEBUG) messages that I'm getting from my session using
>> >> log4j.
>> >> From the Content-disposition: attachment; filename="myfile.csv"
>> response
>> >> header I see that there is a file myfile.csv to be downloaded, I just
>> >> don't
>> >> know how to do it.  If I paste the same GET into a web browser, I do
>> get
>> >> the
>> >> file.
>> >>
>> >> I changed the reader code as follows:
>> >> int buf = new int[10000]; int ptr = 0;
>> >> while (true) {
>> >>   buf[ptr++] = reader.read();
>> >> }
>> >>
>> >> All that I end up reading is 13,10 followed by lots of -1 values.
>> >>
>> >
>> > That's because there is no content.
>> >
>> > Oleg
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Read-attached-file-from-webpage-tp25358160p25364070.html
>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Read-attached-file-from-webpage-tp25358160p33047167.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to