Header "malformed syntax"
Hey folks. :)
Here are the details:
And here is the server response:
char ServerName = "www.example.com";
char FilePath = "/index.html";
strcat(storage, " HTTP/1.1\ Host: ");
strcat(storage, " \r\n\r\n");
iResult = recv(ConnectSocket,storage,STORAGE_LEN,0);
I am getting this type of message from all servers that I have tried to connect to.
HTTP/1.1 400 Bad Request
Date: Wed, 11 Mar 2009 10:38:55 GMT
Server: Apache/2.2.3 (CentOS)
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<title>400 Bad Request</title>
<p>Your browser sent a request that this server could not understand.<br />
<address>Apache/2.2.3 (CentOS) Server at www.example.com Port 80</address>
A search on google shows that "HTTP/1.1 400 Bad Request" means the header has a "malformed syntax", but I have not been able to find a working solution.
This code below works for some webpages with small amounts of content(a few hundred characters), but for lots of content(a whole page of text), the server resends parts of the content.
Can someone please point me in the right direction?
strcpy(storage, "GET / \r\n");
strcat(storage, "HTTP 1.0 \r\n\r\n");
Thanks in advance. :)
EDIT: If I was to use the above code, for www.example.com, here is the server response:
But the server doesn't provide the time, or date, or bytes returned, or the server OS etc.
<TITLE>Example Web Page</TITLE>
<p>You have reached this web page by typing "example.com",
"example.net", or "example.org" into your web browser.</p>
<p>These domain names are reserved for use in documentation and are not available
for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RFC
2606</a>, Section 3.</p>