[b][red]This message was edited by gautam at 2006-9-30 3:13:14[/red][/b][hr]
[b][red]This message was edited by gautam at 2006-9-30 3:12:10[/red][/b][hr]
[b][red]This message was edited by gautam at 2006-9-30 3:11:15[/red][/b][hr]
I am trying to generate a GET request in C code by connecting to the site on port 80. However I get a response as -
400 - Bad Reqest
Your browser sent a request that this server could not understand.
client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /index.html
This is my send request code
int SendRequest(int sockfd, const char *hostname, char *filename)
memset(getReq, '', 4096);
// hostname has the name as "./www.websitename.com"
// hence do not copy first 2 characters
// the actual code does not have space in between
// HTTP / 1.1 but the messageboard makes it into a link
sprintf(getReq, "GET /%s HTTP / 1.1
int len = strlen(getReq);
while(send(sockfd, getReq, strlen(getReq), 0) < len);
I can't figure out what is wrong with the code. Is my GET request not framed properly ?