hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Mauro" <pma...@apparentnetworks.com>
Subject RE: Receiving an attachment through http
Date Wed, 12 Jan 2005 19:59:58 GMT
In addition to the log output I send earlier today, I just run the program HTTP Getter on my
URL and this is the response I got back, hope it helps (the garbage is obviously the pdf file):

1.1 200 OK
content-disposition: attachment; filename=AppareNetReport.pdf
Content-Type: application/pdf
Transfer-Encoding: chunked
Date: Wed, 12 Jan 2005 19:57:51 GMT
Server: Apache Coyote/1.0
Connection: close

800
PDF-1.2 
âãÏÓ 
1 0 obj 
<< 
/Type /Catalog 
/Pages 2 0 R 
/PageMode /UseNone 
/ViewerPreferences << 
/FitWindow true 
/PageLayout /SinglePage 
/NonFullScreenPageMode /UseNone 
>> 
>> 
endobj 
5 0 obj 
<< 
/Length 220 
/Filter [ /FlateDecode ] 
>> 
stream
xœuMOÃ0@ïþîVhÊÚ-v>_‘ç¡H\rcҐØÿ?à´ô°‰9É˳»·­ÎÑ.Ù$ŒW°óáíó/y{…ç´„.*æ+ÙZÌ0ͦÙn¶mûÐcþ‚—?@É1†äQ„Ùãíïð}'S&à4Iµ™Ç®˜Ò?í†qX53´ˆ¤„ªãGµ‹njDá?{½'"»Ø-Ã5.fp~×ñR‘kISé“–AÖŽ÷ýzϺ„8+¹iRÛÎäÈÎ+à$æ“þÇúþObEÁendstream

endobj 
12 0 obj 
<< 
/Length 372 
/Filter [ /FlateDecode ] 
>> 
stream
xœUÒËnƒ0Ð=_1ËV]@0 EHUºÉ¢õˆ=DH‰AYäïë;C#u3غžtx;øq¡ô+L¶ã…†Ñ»À×é,Ó‘O£§MNn´Ëú&«½ô3¥±¹»_¾ü0Ñn—¤ßñãu
wzz
c~Éž)ýŽÃèOôô³ïâ{w›ç3_Ø/”QÛ’ã!I÷ïýüÑ_˜ÒµQx³î69¾Î½åÐûÓ.ß´´3MKìÝÿoI^jËqÐw­•Ë̦r|


-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
Sent: Tuesday, January 11, 2005 11:31 PM
To: HttpClient User Discussion
Subject: Re: Receiving an attachment through http

Hello Patrick,

could you send a wire log so we can see what is actually happening?
http://jakarta.apache.org/commons/httpclient/logging.html

I have two other possible explanations for the behavior you described:

1) the server sends an HTTP redirect which is not handled
    automatically by HttpClient for some reason

2) the server sends an HTML page with some JavaScript
    or META tag in it that triggers a redirect

cheers,
  Roland





"Patrick Mauro" <pmauro@apparentnetworks.com>
12.01.2005 05:02
Please respond to
"HttpClient User Discussion"


To
<httpclient-user@jakarta.apache.org>
cc

Subject
Receiving an attachment through http






Hi, I've got a situation where I make a request to a webserver,
http://server/foo.do?param=value <http://server/foo.do?param=value> .
The response is a webpage and a pdf attachment.  I've gotten it to work
if I use my web browser, if I connect to the url with my web browser I
get prompted to save or open the pdf.  However, when I try this through
httpclient I'm only getting the html page (which is never seen from the
web browser).
 
Here's my code for trying read the pdf from the http response:
 
GetMethod fileGet = new GetMethod(urlWithparameters);
HttpClient client = new HttpClient();
// this defines the protocol, host and port number for the connection
client.setHostConfiguration(
ProxyServices.getSysConfigServices().getWebServerConfig());
client.setConnectionTimeout(5000);
int status = client.executeMethod(fileGet);
// ... check for status codes in here
byte[] pdf = fileGet.getResponseBody();

My current theory as to why this doesn't work for me is that I believe
the server transmits the pdf through content-disposition=attachment
which I just read is not a core part of the http spec and is in fact a
seperate spec in its own right.  Plus, my understanding is that
HttpClient is intended to cover the core functionality of http...

If I'm not doing this right, any help would be greatly appreciated.  Or,
if my theory is correct, what package I might go through to resolve this
would be immensly helpful.

 

Thanks a lot!  Great package!

Patrick Mauro 


Mime
View raw message