现在的位置: 首页 > 综合 > 正文

HTTP Content-Type/multipart:form-data; boudary=..

2018年02月16日 ⁄ 综合 ⁄ 共 1360字 ⁄ 字号 评论关闭

对于HTTP的multipart的形式,具有严格的格式要求,其中主要有,

    1. 分界符号,--${boundary}

    2. 结束符号,--${boundary}--

    3. 以及必须的/r/n(0x0D0A).

    以下是ASP.net的可以正确解析的的请求,其中,每个对象是一个以name为key的一个map对象。

 

注意:今天发现由于boundary写成了一个特定值不改变,被WAF防火墙的策略认定为跨站攻击。被阻断了。

             后来发现是由于httpConn.setChunkedStreamingMode( 0 );设置了这个,好像就被拦住了。是不是设置了这个,就不会设置length了。


             HttpClient的实现,http://hc.apache.org/downloads.cgi 
- 其中有boundary的生成实现。

             RFC文档,http://www.faqs.org/rfcs/rfc1867.html

 

POST /customer-mainapp-uploadimage/UploadImage.ashx HTTP/1.1

Host: x.com

Accept-Encoding: gzip, deflate

Content-Type: multipart/form-data;boundary=**--------------------7de32683115e

Accept-Language: en-us

Accept: */*

Pragma: no-cache

Content-Length: 11461

Connection: keep-alive

User-Agent: CTRIP_WIRELESS/5.8CFNetwork/672.0.8 Darwin/13.2.0

  [/r/n] -below is multi-entity.

--**--------------------7de32683115e

Content-Disposition: form-data;name="AuthToken"

  [/r/n]

3D41988DB54DE4323C9FE7886FEE387493F863D9120D38661F028A24DE11122

--**--------------------7de32683115e

Content-Disposition: form-data;name="ChannelType"

 [/r/n]

APP

--**--------------------7de32683115e

Content-Disposition: form-data;name="Image"; filename="/Users/ctrip/Library/ApplicationSupport/iPhoneSimulator/7.0.3/Applications/D28E2484-1D3F-41F1-8238-09E0E193CBD9/tmp/1405840249_avatar_180_180.jpg"

Content-Type: image/jpeg

[/r/n]

picture binary data....

--**--------------------7de32683115e--

[/r/n]

 

抱歉!评论已关闭.