400 Bad Request
Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NexusOrganicus

HTTP-request- NEED HELP - please

This topic is 5493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Gurus // and code junkies i need your help i wrote a little programm to receive html files from a specific url for example www.google.com my problem is the http request: sprintf (command, "GET %s HTTP/1.0\nHost: %s\n\n",file,host); /* send */ bytes_sent = send (sock, command, strlen (command), 0); i connect but then the server sends me the information that he couldn´t received the host name server error message 400 ::request without hostname :: can you tell me why ?? the host name is in my example www.google.com // am i right ? ______________________________________________________________ thanks for reading through and im sorry for my bad english nXo

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by NexusOrganicus
sprintf (command, "GET %s HTTP/1.0\nHost: %s\n\n",file,host);
\n will give you ASCII 10 (LF), I believe. You need ASCII 13+10 (CRLF).

Share this post


Link to post
Share on other sites
i am sorry
you mean the two \n\n
what should i write instead ?
i am not sooo good in programming
i am sorry but
>You need ASCII 13+10 (CRLF).
how can i include that one ?
thx
iam sorry
nXo

Share this post


Link to post
Share on other sites
to solve that ....? am iright please correct me
i know that i may be an idiot ..

is it possible to solve the problem that way

char CRLF=23;

sprintf(command,"GET %s HTTP/1.1%c%cHost: http://%s%c.....blabla
???????
not really ? or
nxo

Share this post


Link to post
Share on other sites
Nothings working at all
i am not receiving any message from the server ....

/////////////////////////////////////////////////////////
sprintf(command,"HEAD %s HTTP/1.1\r\n"
"Host: http://%s\r\n",file,ipadr);
send(sockfd,command,strlen (command),0)
while((recv(sockfd,buffer,strlen (buffer), 0))>0)
{
printf("%s",buffer);
}
////////////////////////////////////////////////////////

i don´t know why it isn´t working..........
\r\n does nothing i don´t get any data sent from the server
what should i do ?
is the problem the http protokol or is it me ?
maybe you have other suggestions
thx
nxo

Share this post


Link to post
Share on other sites
quote:

sprintf(command,"HEAD %s HTTP/1.1\r\n"
"Host: http://%s\r\n",file,ipadr);


You need to end the header with a double CRLF.

sprintf(command,"HEAD %s HTTP/1.1\r\n"
"Host: http://%s\r\n\r\n",file,ipadr);

With a single CRLF, the server is just sitting there and waiting for you to either send another CRLF or send more options in the header. It won''t send anything to you before you have sent a double CRLF.

Share this post


Link to post
Share on other sites
Ok it works but only on www.google.com
on other sides i geth this message ___



148



Bad Request


Your browser sent a request that this server could not understand.


Invalid URI in request GET *.html HTTP/1.1




Apache/1.3.26 ServHTTP/1.1 400 Bad Request

Date: Thu, 05 Jun 2003 13:22:51 GMT

Server: Apache/1.3.26 (Unix) PHP/4.0.6

Connection: close

Transfer-Encoding: chunked

Content-Type: text/html; charset=iso-8859-1

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!