HTTP GET in C++

Hello everyone,

I am using the code in the following website (http://www.adp-gmbh.ch/win/misc/sockets.html#test) that is a ready Socket and Client class for connecting to a website. But in the Client.cpp code, if I put a query for Google instead of the host name in the send() method, I get a bad response.
1
2
3
s.SendLine("GET / HTTP/1.0");
s.SendLine("Host: www.google.com/search?hl=en&q=chair");
s.SendLine("");

does not work, and
1
2
3
s.SendLine("GET / HTTP/1.0");
s.SendLine("Host: www.google.com");
s.SendLine("");

works... And SendLine is just a call to send() in WinSock2.h.

Anyone has any ideas?

THANKS!
Of course the first one won't work.
This
"www.google.com/search?hl=en&q=chair
is not a host name is it?????????????????

put the query in the first line of the GET

1
2
3
s.SendLine("GET /search?hl=en&q=chair HTTP/1.0");
s.SendLine("Host: www.google.com");
s.SendLine("");



Last edited on
Thankssssss!!!!!!!
Topic archived. No new replies allowed.