HTTP POST REQUEST C++

Viewed 523

I have been stuck on a small piece of code trying it out.

            char httpRequest[] = "POST http://myhost.com/ HTTP/1.1\r\n"
            "Host: myhost.com\r\n"
            "Content-Type: application/x-www-form-urlencoded\r\n"
            "Content-Length: 10\r\n"
            "Connection: close\r\n"
            "\r\n"
            "text1=test";

sock_error2 =  send(tcpsock, httpRequest, strlen(httpRequest) + 1, 0);

The request never reaches the destination server, i have packet dump on both sides.

Whenever i change content-length to 0, the packet is received by the server without the body of course. What am i doing in wrong in content-length or carriage returns?

0 Answers
Related