hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhenyu Wang" <zhe...@rentmarketer.com>
Subject Re: Problem with MultiPart Post - Uploading image
Date Thu, 14 Dec 2006 18:39:38 GMT
Hello Roland,

I can catch what the browser and httpclient send through TCPMon tool (see
the below).  You can see there are quite different in both header and body
sections.  Question is what I should do to make my code to send exactly the
same as the browser does?

HTTPClient sends:
---------------------------------------------------------------------------------------------------------------------------------------
POST /index.cfm?fuseaction=lmanage.editListingPhoto HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.0.1
Host: www.apartmentfrog.com
Cookie: $Version=0; CFID=1108839; $Path=/
Cookie: $Version=0;
CFTOKEN=d1b690cd1acf9a79-8213869B-C51B-A0AA-470EC106CB9422E6; $Path=/
Cookie: $Version=0; JSESSIONID=c8307c79598c623d7b4e; $Path=/
Content-Length: 11254
Content-Type: multipart/form-data;
boundary=Q8Q7z887xNVDp38wYwwEPreXSXKFNuPihInCt

--Q8Q7z887xNVDp38wYwwEPreXSXKFNuPihInCt
Content-Disposition: form-data; name="AFID"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

3775
--Q8Q7z887xNVDp38wYwwEPreXSXKFNuPihInCt
Content-Disposition: form-data; name="useraction"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

uploadphoto
--Q8Q7z887xNVDp38wYwwEPreXSXKFNuPihInCt
Content-Disposition: form-data; name="photocaption"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit


--Q8Q7z887xNVDp38wYwwEPreXSXKFNuPihInCt
Content-Disposition: form-data; name="photofile"; filename="love.jpg"
Content-Type: image/jpeg; charset=UTF-8
Content-Transfer-Encoding: binary
 ........ binary code
--Q8Q7z887xNVDp38wYwwEPreXSXKFNuPihInCt--

Browser Send:
-----------------------------------------------------------------------------------------------------------------------------
POST /index.cfm?fuseaction=lmanage.editListingPhoto HTTP/1.1
Host: www.apartmentfrog.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8)
Gecko/20061025 Firefox/1.5.0.8
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer:
http://www.apartmentfrog.com/index.cfm?fuseaction=lmanage.editListingPhotoForm&AFID=3766
Cookie: CFID=1106548;
CFTOKEN=905a3588a60294cb-7E7DDD76-C3A5-8795-939DB218C66689EC;
JSESSIONID=c830101025f739275d7f
Content-Type: multipart/form-data;
boundary=---------------------------23281168279961
Content-Length: 10993

-----------------------------23281168279961
Content-Disposition: form-data; name="AFID"

3766
-----------------------------23281168279961
Content-Disposition: form-data; name="useraction"

uploadphoto
-----------------------------23281168279961
Content-Disposition: form-data; name="photocaption"


-----------------------------23281168279961
Content-Disposition: form-data; name="photofile"; filename="love.jpg"
Content-Type: image/jpeg

........................ binary code


Thanks,
Marshall


On 12/13/06, Roland Weber <ROLWEBER@de.ibm.com> wrote:
>
> Hello Marshall,
>
> > It's a really good documentation!
>
> Thanks :-)
>
> > I used a tool called TCPMON to catch the
> > request header, and the following is what I got:
> >
> > POST /index.cfm?fuseaction=landlords.ListingValidate HTTP/1.1
> > User-Agent: Jakarta Commons-HttpClient/3.0.1
>
> You can see what HttpClient is sending by enabling the wire log:
> http://jakarta.apache.org/commons/httpclient/logging.html
>
> The question is: what does the _browser_ send, and what
> are the differences to what HttpClient is sending?
>
> cheers,
>   Roland
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message