English 中文(简体)
Help, don t know what s wrong with my HTTP multipart POST
原标题:
POST /upload HTTP/1.1
Host: assets.drop.io
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2
009042316 Firefox/3.0.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Length: 5728
Content-Type: multipart/form-data; boundary=--------MalolHCBdarysNYMHZbIvjbD


--------MalolHCBdarysNYMHZbIvjbD
Content-Disposition: form-data; name="api_key"

0b8a12109c3a1bfc4ba94aec926e1f9cfd8bb6f0
--------MalolHCBdarysNYMHZbIvjbD
Content-Disposition: form-data; name="drop_name"

4pgvoxc
--------MalolHCBdarysNYMHZbIvjbD
Content-Disposition: form-data; name="version"

2.0
--------MalolHCBdarysNYMHZbIvjbD
Content-Disposition: form-data; name="rachel"; filename="rachel"
Content-Type: application/octet-stream

BMv¶
--------MalolHCBdarysNYMHZbIvjbD--

The response I get is: Bad Request. And in the HTML of the response there is this:

:MultiPartParseError: bad content body:
 
----------MalolHCBdarysNYMHZbIvjbD  should ==  ----------MalolHCBdarysNYMHZbIvjbD
 ></td></tr>
最佳回答

The answer is in your question. The response says that the divider should be ----------MalolHCBdarysNYMHZbIvjbD instead of ----------MalolHCBdarysNYMHZbIvjbD

Look at the leading and trailing spaces.

问题回答

The schematic syntax of a multipart/form-data message is as follows:

Content-Type: multipart/form-data; boundary=boundary

--boundary
Content-Disposition: form-data; name="field 1"

data 1
--boundary
Content-Disposition: form-data; name="field 2"

data 2
⋮
--boundary
Content-Disposition: form-data; name="field N"

data N
--boundary--

So the inner part boundaries are --boundary (-- followed by the boundary value) and the last is --boundary-- (-- followed by the boundary value followed by --).

In your case you are just missing the leading --.





相关问题
How to set response filename without forcing "save as" dialog

I am returning a stream in some response setting the appropriate content-type header. The behavior I m looking for is this: If the browser is able to render content of the given content type then it ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Does HttpWebRequest send 200 OK automatically?

Background: I am implementing Paypal IPN handler. This great article on Paypal states that I am required to send a 200 OK back to Paypal after I read the response. The processing of IPN request is ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

Finding out where curl was redirected

I m using curl to make php send an http request to some website somewhere and have set CURLOPT_FOLLOWLOCATION to 1 so that it follows redirects. How then, can I find out where it was eventually ...

热门标签