I'm begging for help: multipart/form-data request rejected by server - Help
This is a discussion on I'm begging for help: multipart/form-data request rejected by server - Help ; I have a problem which is driving me mad because I seem to be doing
everything
like I should and yet I'm getting and error message.
I wrote an application which sends an HTTP request to the server. This is ...
-
I'm begging for help: multipart/form-data request rejected by server
I have a problem which is driving me mad because I seem to be doing
everything
like I should and yet I'm getting and error message.
I wrote an application which sends an HTTP request to the server. This is a
POST
request and I cite it at the end of this message. In my opinion it is fully
compatible with the multipart/form-data content type specification. But my
server rejects it and return a 400 Bad Request error. Why? Do you have any
idea?
POST /test.php HTTP/1.1
User-Agent: UNTRUSTED/1.0
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
Content-Type: multipart/form-data; boundary=--boundary---
Content-Length: 9658
Host: www.myserver.com
Transfer-Encoding: chunked
000000 39 61 34 0D 0A 2D 2D 62 6F 75 6E 64 61 72 79 2D 9a4..--boundary-
000010 2D 2D 0D 0A 43 6F 6E 74 65 6E 74 2D 44 69 73 70 --..Content-Disp
000020 6F 73 69 74 69 6F 6E 3A 20 66 6F 72 6D 2D 64 61 osition: form-da
000030 74 61 3B 20 6E 61 6D 65 3D 22 44 61 6E 65 5A 64 ta; name="Custom
000040 6A 65 63 69 61 22 0D 0A 0D 0A 30 30 30 30 30 30 erDta"....000000
000050 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
(...) - Here go another 2000 zeros which act as test values that should be
assigned to the CustomerDta variable.
000990 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
0009A0 30 30 30 30 30 30 30 30 30 0D 0A 39 61 34 0D 0A 000000000..9a4..
0009B0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
(...)
001330 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
001340 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
001350 30 30 30 30 0D 0A 39 61 34 0D 0A 30 30 30 30 30 0000..9a4..00000
001360 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
(...)
0025B0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
0025C0 30 30 30 0D 0A 2D 2D 62 6F 75 6E 64 61 72 79 2D 000..--boundary-
0025D0 2D 2D 0D 0A 0D 0A 30 0D 0A 0D 0A --....0....
-
Re: I'm begging for help: multipart/form-data request rejected byserver
Piter wrote:
> I have a problem which is driving me mad because I seem to be doing
> everything
> like I should and yet I'm getting and error message.
>
> I wrote an application which sends an HTTP request to the server. This is a
> POST
> request and I cite it at the end of this message. In my opinion it is fully
> compatible with the multipart/form-data content type specification. But my
> server rejects it and return a 400 Bad Request error. Why? Do you have any
> idea?
>
It looks like your boundaries are wrong. The dashes aren't specified as
part of the boundary string on the Content-Type line. Use something
like "boundary=boundary"; then start the content with "--boundary" (i.e.
your boundary prefixed by two dashes) and end it with "--boundary--"
(i.e. same as above with two more dashes at the end).
The full MIME spec for multipart messages is in RFC 1341:
http://www.faqs.org/rfcs/rfc1341.html.
> Content-Type: multipart/form-data; boundary=--boundary---
>
> 000000 39 61 34 0D 0A 2D 2D 62 6F 75 6E 64 61 72 79 2D 9a4..--boundary-
> 000010 2D 2D 0D 0A 43 6F 6E 74 65 6E 74 2D 44 69 73 70 --..Content-Disp
>
> (...)
>
> 0025B0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
> 0025C0 30 30 30 0D 0A 2D 2D 62 6F 75 6E 64 61 72 79 2D 000..--boundary-
> 0025D0 2D 2D 0D 0A 0D 0A 30 0D 0A 0D 0A --....0....
--
Andrew
-
Re: I'm begging for help: multipart/form-data request rejected by server
On Tue, 29 Mar 2005 20:33:21 +0200, "Piter"
wrote:
>I wrote an application which sends an HTTP request to the server.
This was sent to two newsgroups, neither of which has anything to do
with your question. I notice you got an answer, and I'm glad for you.
However, in the future, try picking your groups more appropriately, as
you'll probably have better luck. Hope everything goes well with your
app!
--
Joe Zeff
The Guy With the Sideburns
The only problem with troubleshooting is that
trouble sometimes shoots back.
http://www.lasfs.org http://home.earthlink.net/~sidebrnz
-
Re: I'm begging for help: multipart/form-data request rejected by server
I've done this sort of programming before. It's been awhile though. My
advice is to load up Squid, set firefox to use it as proxy, and do a
normal form post from firefox to your local Apache web and PHP server
instead of through your application. Then, compare the results by
looking in Squid's log file. You'll have to turn on full logging. If
they differ, then perhaps you need to make your byte stream look more
like the byte stream that firefox sends.
BTW, if you're new to Squid and can't seem to install it properly, then
install a free copy of RH9 (which many vendors sell for like $4 to burn
the CDRs for you, and usually under a different name). It comes with
Squid. Fedora probably does to, but I've only used RH9 for now.
Another route is to use netcat (known as nc) and make it pretend to be
a webserver, ready to receive the web post from firefox. This will
generate an output that you can compare to what your application is
generating.
And then there's also the original RFC spec., but I bet you've already
poured over that for hours and hours.