0

I happen to be writing a very simple text browser, and I'm having a problem connecting to servers using HTTP1.1 GET messages... HTTP1.0 works fine, I just have a string like this:

const char *request = "GET / HTTP/1.0\n\n";

This works great, and I receive my html back from the host just fine. But when I change it to a HTTP1.1 request, I get nothing back...

//  Assuming that I'm connecting to google...
const char *request = "GET / HTTP/1.1\nHost: www.google.com\n"

Any ideas as to why I'm not getting anything back from the server?

-Fredric

3
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by Daishi
0

Hmm, perhaps you need another newline all by itself?

Try

//  Assuming that I'm connecting to google...
const char *request = "GET / HTTP/1.1\nHost: www.google.com\n\n"
0

That doesn't seem to work, although it should. I have no idea what's going on, I think I'll just have to settle with HTTP1.0...

-Fredric

0

this should work:
const char *request = "GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n"

http protocol uses \r\n as a new line, and the last line must always be empty.

0

I put the \r in there, and I started getting data from the server!

Thanks. :)

-Fredric

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.