sending HTTP POST data with Socket
Hi Im trying to send a HTTP POST Request data content to a server using C socket
Everything seemed to work fine except this part
Quote:
fprintf(http->file, "POST
http://some url with POST form in php HTTP/1.1\r\n");
fprintf(http->file, "Host: hostname\r\n");
fprintf(http->file, "Content-Type: applicationx-www-form-urlencoded\r\n");
fprintf(http->file, "Content-Length: 10\r\n\r");
fprintf(http->file, "name=kkkkk\r\n");
fprintf(http->file, "\r\n");
http->file is file pointer to an open socket
the page on the server looks something like this
Quote:
<html>
<head>
</head>
<body>
</Form>
<?php
$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>
however when I tried to run the program
it gives me
Quote:
<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%3Dkkkkk</PRE>
<P>
</BODY></HTML>
I only encountered the above problem if i included the POST data content in the request
Quote:
fprintf(http->file, "Content-Length: 10\r\n\r");
fprintf(http->file, "name=kkkkk\r\n");
do you guys have any idea where did i go wrong ?
thanks