HTTP request help

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

HTTP request help

Post by ayu »

Been a long day so maybe I'm just tired.
But I just can't seem to get this right.

This is a rather simple HTTP request that uploads a file.

Code: Select all

POST /sql.php HTTP/1.1\r\n
Host: 192.168.0.15\r\n
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0\r\n
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n
Accept-Language: en-US,en;q=0.5\r\n
Accept-Encoding: gzip, deflate\r\n
Connection: keep-alive\r\n
Content-Type: multipart/form-data; boundary=---------------------------42419928114728521141917828577\r\n\r\n

-----------------------------42419928114728521141917828577\r\n
Content-Disposition: form-data; name="userfile"; filename="payload-small.txt"\r\n
Content-Type: text/plain\r\n\r\n

aaaaaa\n
aaaaaa\r\n
-----------------------------42419928114728521141917828577--\r\n\r\n
But for some reason the file doesn't get uploaded.
If I use a regular form to do it then it works, and I have just about copy/pasted the data now from the original request into my python script.
I get HTTP 200/OK back, but the files do not show up.
The usual trouble is newlines and carriage return, but I think I got it right ....

Any ideas?
"The best place to hide a tree, is in a forest"

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: HTTP request help

Post by ayu »

bleh, solved it.
Each row in the string added an extra newline, so it became \r\n\n.
Now I just need to get it to work in my script :F
"The best place to hide a tree, is in a forest"

Post Reply