overtaker Posted September 6, 2006 Share Posted September 6, 2006 Hi currently im developing a C program using socket to send POST REQUEST to a http serveri tried to send:POST http://someurl HTTP/1.1HOST: hostnameContent-Type: applicationx-www-form-urlencodedContent-Length: 10name=kkkkkto the server which has<html><head></head><body>$name = $_REQUEST[name];if($name == NULL){ print('<Form action=info.php method=POST><input type="text" name="name"/><input type="submit"/></FORM>');}else{ print($name);}?></body></html>but I got these insteadHTTP/1.1 400 Bad RequestDate: Wed, 06 Sep 2006 15:47:06 GMTServer: Apache/1.3.34 (Unix) mod_perl/1.29Connection: closeTransfer-Encoding: chunkedContent-Type: text/html; charset=iso-8859-1126<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>400 Bad Request</TITLE></HEAD><BODY><H1>Bad Request</H1>Your browser sent a request that this server could not understand.<P>Request header field is missing colon separator.<P><PRE>name=kkkkk</PRE><P></BODY></HTML>what was wrong with my POST request ?note that if i did not incorporate content-length and the post content it works finethanks a lot for any help Link to comment Share on other sites More sharing options...
justsomeguy Posted September 6, 2006 Share Posted September 6, 2006 I believe you need a blank line between the headers and the request. You can always check the HTTP specs and see for yourself though, make sure you are also sending the proper line endings. Link to comment Share on other sites More sharing options...
overtaker Posted September 7, 2006 Author Share Posted September 7, 2006 hi, can you give me an url for the HTTP specs, I have problem finding a proper one with detailed specificationthanks Link to comment Share on other sites More sharing options...
justsomeguy Posted September 7, 2006 Share Posted September 7, 2006 You want detailed? Here you go:RFC 2616: Hypertext Transfer Protocol version 1.1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now