Archived

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

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

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 on other sites
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 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 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 on other sites
thanks
i´ll try in a sec
_________________
thanks
nxo

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

/////////////////////////////////////////////////////////
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 on other sites
printf the string and write here what it says.

~CGameProgrammer( );

Share on other sites
quote:

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 on other sites
Ok it works but only on www.google.com
on other sides i geth this message ___

148

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

Invalid URI in request GET *.html HTTP/1.1

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

• 48
• 12
• 10
• 10
• 9
• Forum Statistics

• Total Topics
631374
• Total Posts
2999661
×