4

Learning HTTP from tutorialspoint

In the URI section (third method), it says that a request to www.w3.org would open a TCP connection to port 80 and send the following request line/s:

GET /pub/WWW/TheProject.html HTTP/1.1
Host: www.w3.org
 

At initial request, how would does the client end device know the specific .html filename to grab? If it were index.html or one of the default ones, I'd understand, but TheProject.html is not.

  • 1
    Quite simply the system doesn't. The entire thing is the URL which has been requested - this can either be typed in at the command line or a link from another site (eg a search) – davidgo Jul 12 '16 at 6:27
7

When you click on a link in a web page, it has the filename that is to be requested. Hover your mouse over the turorialspoint link you have posted:

http://www.tutorialspoint.com/http/http_requests.htm

This translates to

GET /http/http_requests.htm HTTP/1.1
Host: www.tutorialspoint.com
 

In the absence of a specific file, the url would be http://www.tutorialspoint.com/. This translates to:

GET / HTTP/1.1
Host: www.tutorialspoint.com
 

Web servers are configured with what is called an index file or default file. This is the file that gets served from a directory when no specific filename is requested. Often this is index.html or default.htm or index.php, or multiples of these, which are tried in turn until one is found.

  • Cool. So how/where is this index or default file defined or configured? – tjt263 Jul 12 '16 at 9:23
  • 3
    In the webserver configuration. The client has nothing to do with that. The webserver should return some document when the client requests a directory (like the root directory / ). In the early days of the web, most servers would just return a directory listing, but now usually some document is returned. – Josef Jul 12 '16 at 10:09
  • @tjt263, Apache uses the DirectoryIndex setting. IIS from Microsoft also has a default document setting. You can also configure the web server to generate automatically a listing of the requested directory, see for example the mod_autoindex module from Apache. – Cristian Ciupitu Jul 12 '16 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.