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

对于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]

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值