U1L13 Resource - HTTP and Abstraction On The Internet
U1L13 Resource - HTTP and Abstraction On The Internet
HTTP (HyperText Transfer Protocol)
HTTP is a high level protocol, that defines how users of the Internet (clients)
request and receive data like web pages, images, video, audio, and files from
the servers containing them. A client will send a request to the server with an
identifier for a desired piece of data, and the server will attempt to respond to
the request, typically by returning the information requested.
HTTP Requests
When you type a URL in your browser, your computer (the client) needs to “ask” the server that is storing the data and
images for the web page to return its contents so your browser can display it. To do so, your computer will send an
ASCII-text message called an HTTP request. Here’s what a simple HTTP request for the data of an image might look like:
● Method: An HTTP request will begin with a method, which indicates what the client wants the server to do. The
two most common methods are:
Method Description
● Resource: The name of the resource you wish to access. In the example above, the request is for a .png image
called “logo” located in the folder “images.”
● HTTP Version: An indication of the version of HTTP being used; in this example it is HTTP 1.1.
● Headers: Additional information included to help the server interpret the request. In the above example, “Host” is
included, but many more can be added by placing them on additional lines.
HTTP Response
When a server receives an HTTP request it will respond with a message of its own. Once again, the response will be sent
entirely in ASCII-text and must be correctly formatted. Here’s a sample HTTP Response:
● HTTP Version: An indication of the version of HTTP being used; in this example it is HTTP 1.1.
● Status Code and Reason Phrase: A number and phrase indicating how the server responded to the request.
Some common Status Codes / Reason Phrases are:
404 Not Found Server could not find anything matching request
500 Internal Server Error Error by the server prevented fulfilling request
● Headers: Additional information about the response. The example above includes the header “Content-Type,”
indicating the type of content included in the response.
● Body: Following the headers, the response may include some data that was requested. In this example the actual
binary representation of the image would be included in the response, so this response could be quite long.
HTTP as Abstraction
HTTP specifies how requests and responses should be formatted but does not mention how this text will actually be sent.
You could conduct an HTTP exchange with a friend by writing hand-written letters and mailing them to one another, so
long as your letters were formatted according to HTTP. In the real world, HTTP exchanges are conducted over TCP/IP,
but this is not the concern of HTTP. It simply requires that some system be in place for these messages to be sent back
and forth. In this way, HTTP uses lower-level systems abstractly, relying on their functionality without concern for the
details of how that functionality is achieved.