Click here to Skip to main content
15,175,960 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Can anyone tell me what is wrong with this HTTP POST packet? The web server seems to be ingoring it.

Prior to URLEncoding and without Base64 encoded data:
"POST /Default.aspx HTTP/1.1\r\nHost: www.host1.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 17\r\n\r\ndata=TestDataSend"


Post encoding:
"POST+%2fDefault.aspx+HTTP%2f1.1%0d%0aHost%3a+vztest.cloudapp.net%0d%0aContent-Type%3a+application%2fx-www-form-urlencoded%0d%0aContent-Length%3a+17%0d%0a%0d%0adata%3dVGVzdERhdGFTZW50"


The end of the packet ("data%3dVGVzdERhdGFTZW50") is data=TestDataSend which is what I am trying to send.

If you are wondering, this is for an embedded application. I am trying not to use the entire HTTP protocol and just use a simplified POST.

Thanks for any insight.
Posted
Updated 27-Jul-11 12:56pm
v4
Comments
Christian Graus 27-Jul-11 14:00pm
   
You can't use ASP.NET with C++
willworknow1 27-Jul-11 14:41pm
   
I do understand that. The reason for the C++ tag is someone with C++ knowledge could also know the answer to this question. They might have more intimate knowledge of the HTTP protocol.
Sergey Alexandrovich Kryukov 27-Jul-11 17:35pm
   
You could use C++/CLI or mixed-mode solution with ASP.NET, so knowledge of C++ people might help.
--SA

1 solution

The server should accept the "Prior to URLEncoding" snippet. Cause thats correct. You have to encode the post data only.
Regards.
   
Comments
willworknow1 28-Jul-11 15:17pm
   
Is that just like it is...with spaces, forward slashes etc? The above still does not seem to be working for me.
mbue 28-Jul-11 16:24pm
   
Cant recognize the kind of the data encoding. The http header has not to be encoded - except the location (path and host when neccessary [1]) the data (urlencoded) has to be encoded in percent encoding [2].
Regards.

[1] http://www.ietf.org/rfc/rfc1738.txt
[2] http://en.wikipedia.org/wiki/Percent-encoding
willworknow1 29-Jul-11 18:34pm
   
This is what worked.
"POST /Default.aspx?data=VGVzdERhdGE%3d HTTP/1.1\r\nHost: vztest.cloudapp.net\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 0\r\n\r\n";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900