Swen Kooij
Swen Kooij

Reputation: 995

Raw Http: Handle subdomain

I'm practising raw HTTP requests with sockets. I understand how the HTTP protocols works (in basic) and I know how to build a request.

Currently my basic HTTP request is:

GET / HTTP/1.1
Host: google.com
Connection: Close

When I want to request google.com/toll.php (which ofcourse does not exists):

GET /toll.php HTTP/1.1
Host: google.com
Connection: Close

But what if I have an url that contains a subdomain, like:

lol.google.com/toll.php 

Should the request be:

GET /lol/toll.php HTTP/1.1
Host: google.com
Connection: Close

or should it be:

GET /toll.php HTTP/1.1
Host: lol.google.com
Connection: Close

This problem is driving me nuts! I've read the .NET documentation and sockets and some documentation on the HTTP protocol. I also googled on many terms, but still.. I'm unable to find the answer.

I'm using C# (.NET) and I'm aware that there is no need to write an HTTP class or do manual HTTP request since we have the HttpWebRequest class. This is just for learning purposes.

Thanks in advance. Swen

Upvotes: 0

Views: 220

Answers (1)

spender
spender

Reputation: 120518

It should categorically be

GET /toll.php HTTP/1.1
Host: lol.google.com

Http makes no distinction between domains and subdomains. They're all simply hosts with different names.

Upvotes: 2

Related Questions