Copyright © tutorialspoint.com
To retrieve the file at the URL http://www.somehost.com/path/file.html first open a socket to the host www.somehost.com, port 80 (use the default port of 80 because none is specified in the URL). Then, send something like the following through the socket:
The server should respond with something like the following, sent back through the same socket:
After sending the response, the server closes the socket. To familiarize yourself with requests and responses, do manually experiment with HTTP using telnet. Manually Experimenting with HTTPUsing telnet, you can open an interactive socket to an HTTP server. This lets you manually enter a request, and see the response written to your screen. It's a great help when learning HTTP, to see exactly how a server responds to a particular request. It also helps when troubleshooting. From a Unix prompt, open a connection to an HTTP server with something like telnet www.somehost.com 80 Then enter your request line by line, like GET /path/file.html HTTP/1.0 [headers here, if any] [blank line here] After you finish your request with the blank line, you'll see the raw response from the server, including the status line, headers, and message body. |
Copyright © tutorialspoint.com