Hypertext Transfer Protocol (HTTP)

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is HTTP?

HTTP (Hyper Text Transfer Protocol) is an application protocol designed for transmission of hypertext documents on the Internet.

What is the latest version of HTTP?

3

What ports does HTTP use?

80/TCP, 443/TCP (8000,8080,81,etc).

Name a RFC standard for HTTP

<p>RFC 1945 (HTTP/1.0, 1996)</p> Signup and view all the answers

Name a more recent RFC standard for HTTP

<p>RFC 9114 (HTTP/3, 2022)</p> Signup and view all the answers

HTTP/1.1 is backward compatible with HTTP/1.0

<p>True (A)</p> Signup and view all the answers

What transport protocol does HTTP use?

<p>TCP</p> Signup and view all the answers

What is the structure of Client / server communication?

<p>The client sends a message (HTTP request) to the server requesting a resource. The server receives the message, processes it, and responds with an HTTP response message containing the resource asked for.</p> Signup and view all the answers

HTTP is a stateful protocol

<p>False (B)</p> Signup and view all the answers

What does a stateless protocol mean?

<p>It doesn't relate information concerning previous petitions</p> Signup and view all the answers

How are stateless protocols solved?

<p>With cookies, etc.</p> Signup and view all the answers

What year was version HTTP 1.1 released?

<p>1998</p> Signup and view all the answers

What are the parts of an HTTP petition?

<p>Request line, Header lines (0 or more), Blank line (CR/LF), Request body (in case of POST request)</p> Signup and view all the answers

What is the function of the Method in the Request line?

<p>Action to perform (Verb).</p> Signup and view all the answers

What is the function of the Request-URI in the Request line?

<p>Resource requested</p> Signup and view all the answers

Name three Methods

<p>GET, HEAD, POST</p> Signup and view all the answers

Describe the GET method

<p>Retrieve Request-URI</p> Signup and view all the answers

What is the structure of an HTTP Response?

<p>HTTP-Version Status-Code Reason-Phrase CRLF, field-name: [field-value] CRLF, Blank line (CR/LF), Response body</p> Signup and view all the answers

What type of information does the Status-Code provide?

<p>Response type</p> Signup and view all the answers

What type of information does the Reason-Phrase provide?

<p>Text description of response</p> Signup and view all the answers

HTTP version can the response be?

<p>HTTP/1.0 or HTTP/1.1</p> Signup and view all the answers

Write an easy to read list of the Status code responses:

<p>1** - Hold on, 2** - Done, here you have, 3** - Leave, go another place, 4** - You f<em>ck'd up something, 5** - I f</em>ck'd up something</p> Signup and view all the answers

Host header is mandatory for HTTP/1.1 Clients

<p>True (A)</p> Signup and view all the answers

HTTP/1.1 Clients must accept chunked data responses

<p>True (A)</p> Signup and view all the answers

HTTP 1.1 clients must handle persistent connections

<p>True (A)</p> Signup and view all the answers

Clients must handle: 100 Continue

<p>True (A)</p> Signup and view all the answers

Flashcards

What is HTTP?

An application protocol used for transferring hypertext documents on the Internet.

Common HTTP ports

80/TCP, 443/TCP (common alternatives: 8000, 8080, 81)

HTTP's location in the protocol stack

Application -> HTTP, Transport -> TCP (or UDP HTTP/3), Network -> IP

RFC for HTTP/1.0

RFC 1945

Signup and view all the flashcards

RFC for HTTP/1.1

RFC 2616

Signup and view all the flashcards

Client/Server Communication

The client sends a request to the server; the server processes and responds with the requested resource.

Signup and view all the flashcards

What is a stateless protocol?

The protocol doesn't retain info about previous requests, each stands alone.

Signup and view all the flashcards

HTTP/1.0 Connection Type

Each TCP connection closes after sending the requested resource.

Signup and view all the flashcards

Persistent connections

They keep connections open to transfer multiple resources, saving time and resources.

Signup and view all the flashcards

HTTP Pipelining

Resources parsed during transfer, references requested immediately.

Signup and view all the flashcards

HTTP Request format

Request line, headers, blank line, and request body.

Signup and view all the flashcards

Request line components

Method, URI, HTTP version.

Signup and view all the flashcards

HTTP Method

Action to perform on the resource (e.g., GET, POST).

Signup and view all the flashcards

What is Request-URI?

The specific resource being requested.

Signup and view all the flashcards

HTTP Version

HTTP/1.0 or HTTP/1.1

Signup and view all the flashcards

What is a Header line format?

field-name: [field-value] CRLF

Signup and view all the flashcards

Host Header

Required for all HTTP/1.1 requests

Signup and view all the flashcards

Request Body

Only used in POST requests for sending data to the server.

Signup and view all the flashcards

Common HTTP Methods

GET, HEAD, POST, PUT, DELETE

Signup and view all the flashcards

HEAD Method

Used to retrieve metadata about a URI, check update time, or validate links.

Signup and view all the flashcards

POST Method

Requests server processes data sent in the HTTP request body.

Signup and view all the flashcards

What defines a HTTP Response?

Response line and headers.

Signup and view all the flashcards

What is the HTTP Response format is

HTTP-Version, Status-Code, Reason-Phrase

Signup and view all the flashcards

Status Code

Response result (e.g., 200 OK, 404 Not Found).

Signup and view all the flashcards

Reason Phrase

Human-readable explanation of the status code.

Signup and view all the flashcards

Response Headers

Provide extra details about the response (e.g., Date, Server).

Signup and view all the flashcards

Status Code Categories

1xx, Information; 2xx, Success; 3xx, Redirection; 4xx, Client Error; 5xx, Server Error

Signup and view all the flashcards

HTTP/1.1 Client Requirements

Host header is mandatory, accept chunked responses, handle persistent connections.

Signup and view all the flashcards

What is HTTP Chunked Transfer-Encoding?

Allows server to send data without knowing the total size in advance.

Signup and view all the flashcards

HTTP/1.1 Server Requirements

Servers should require "Host" header, support persistent connections, accept chunked data.

Signup and view all the flashcards

Study Notes

HTTP

  • HTTP (Hyper Text Transfer Protocol) is an application protocol for transmitting hypertext documents on the Internet
  • The latest version of HTTP is 3
  • Ports used are 80/TCP and 443/TCP, additionally 8000, 8080, 81, etc
  • The protocol stack location includes:
    • Application: HTTP
    • Transport: TCP (UDP HTTP/3)
    • Network: IP
  • Standards include:
    • RFC 1945 (HTTP/1.0, 1996)
    • RFC 2616 (HTTP/1.1, 1999) (RFC 9111)
    • RFC 2774 (HTTP/1.2, 2000) (RFC 9112)
    • RFC 7540 (HTTP/2, 2015) (RFC 9113)
    • RFC 9114 (HTTP/3, 2022)
  • The initial HTTP version was HTTP/1.0 (RFC 1945)
  • In 1998, Version 1.1 was released as RFC 2616
  • HTTP/1.1 maintains backward compatibility with HTTP/1.0
  • TCP is the transport protocol used
  • A client sends an HTTP request to the server to request a resource in client/server communication
  • The server processes the message, then sends an HTTP response that contains the resource
  • HTTP is stateless
    • There's no way to relate info to previous petitions, this is solved with cookies

HTTP/1.0

  • HTTP/1.0 relies on non-persistent connections
  • After the server sends the resource, each TCP connection closes
    • Example: https://www.udl.cat/index.html
    • The client creates a TCP connection on port 80 of www.udl.cat server
    • The client sends a request to the server for the desired resource, such as index.html
    • The server receives the request, retrieves /index.html, and sends it back in an HTTP response
    • The server closes the connection
    • The client extracts the HTML document, then parses the data
    • These steps repeat for each resource in the HTML document

HTTP/1.1

  • HTTP/1.1 introduces persistent connections, addressing the issue of excess resource use in HTTP/1.0
  • Connections are kept open, which allows for the transfer of multiple resources
  • Persistent connections enable pipelining
    • No pipelining means each resource transfers completely and is parsed before requesting new resources
    • In pipelining, resources are parsed as transferred and references are requested as they're found
  • Clients must:
    • Mandatory host header
    • Accept responses of chunked data
    • Handle persistent connections by closing all of them when needed
    • Handle 100 Continue
  • Servers should:
    • Require a "Host" header
    • Accept absolute URL in requests
    • It must include the "Date:" header
    • It must indicate the right time as "Date: Tue, 25 Nov 2008 17:15:13 GMT"
    • Accept headers to be sent in chunked data
    • To have persistent connections or include a "Connection: close" on all responses
    • If necessary, use "100 Continue"
    • Accept "If-Modified-Since" / "If-Unmodified-Since"
    • Support GET and HEAD
    • Support HTTP/1.0
  • Must include destination hosts as an option
  • Absolute URLs better solve multi-hosting versus "Host:" headers
  • Absolute URLs are mandatory as of HTTP/1.2 and later
  • Servers must provide responses in the order of the requests if a client has sent them over one connection
  • If a request has a "Connection: close" header, the server needs to close the connection when it responds
  • Servers may close inactive connections after a timeout
  • If a server does not support persistence, it needs to show it in its header
  • Except for 1xx responses (100 Continue), all answers must contain the actual time
  • Servers use it always in GMT

HTTP Petition and Response Formats

  • The format consists of:
    • Request line, header lines (0 or more) + blank line (CR/LF) + request body (if a POST request)
  • Request line Method Request-URI HTTP-version CRLF
    • Method: Action to perform (Verb)
    • Request-URI: Resource requested
    • HTTP-Version: HTTP/1.0, HTTP/1.1
  • Field name and a value delimited by CRLF
    • field-name: [field-value] CRLF
    • As many as needed
    • Mandatory (HTTP/1.1) Host:
  • Request body is only required and used for POST requests
  • The HTTP Response's format contains:
    • HTTP-Version Status-Code Reason-Phrase CRLF field-name: [field-value] CRLF Blank line (CR/LF) Response body
    • Status-Code: type of response
    • Reason-Phrase: Text describing the response
    • HTTP-Version = HTTP/1.0 | HTTP/1.1

Methods

  • GET: Retrieve the request-URI
  • HEAD: Retrieve request-URI headers
    • To get metadata from a URI, to check update time, or validate links
  • POST: Request the server to perform Request-URI with data included in the HTTP request body

Headers

  • Common headers include:
    • Accept, Date, Host, Referer, User-Agent
    • If-Modified-Since (GET), Connection (HTTP/1.1)
    • (BODY) Content-Length (POST), Cache-Control, Cookie

Chunked Transfer Encoding

  • Servers use chunked transfer encoding to send data of unknown total size (e.g., script output, DB query results)
  • The server splits data into chunks and sends them sequentially
  • The response shows "Transfer-Encoding: chunked"
  • All HTTP/1.1 clients should accept this format
  • A chunked message has a sequence of chunks, then a line with 0 and potential footers:
    • Chunk:
    • Start with a line indicating size (hex), then ";" and potential extra parameters, and finally CRLF
    • Then the data follows
    • It ends with CRLF

Chunked vs Non-Chunked

  • Example of chunked transfer:
    • `HTTP/1.1 200 OK Date: Fri, 31 Dec 1999 23:59:59 GMT Content-Type: text/plain Transfer-Encoding: chunked

1a; ignored-stuff-here abcdefghijklmnopqrstuvwxyz 10 1234567890abcdef 0 footer1: value-footer1 footer2: value-footer2 [white line]`

  • Total size: 42 bytes (1a + 10)
  • Equivalent transfer (non-chunked): `HTTP/1.1 200 OK Date: Fri, 31 Dec 1999 23:59:59 GMT Content-Type: text/plain Content-Length: 42

footer1: value-footer1 footer2: value-footer2 abcdefghijklmnopqrstuvwxyz1234567890abcdef`

Connection Handling

  • "Connection: close" usage:
    • The connection will shutdown after the response, when the client has it
    • The client doesn't support persistent connections
    • Is the final request
    • Usage for servers and its implications
    • Servers that close connections without response require client attention
  • If a request is processed and the server is slow, it might reply with the "100 Continue" code to indicate that the request has been received
  • This is followed by the rest of the data
  • Example:
HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Date: Fri, 31 Dec 1999 23:59:59 GMT
Content-Type: text/plain
Content-Length: 42

some-footer: some-value
another-footer: another-value

abcdefghijklmnoprstuvwxyz1234567890abcdef

Status Codes

  • 1xx: Informational
    • 100 Continue
  • 2xx: Request success
    • 200 OK
  • 3xx: Redirects (Resource changed location)
    • 301 Moved Permanently
    • 302 Moved Temporarily
  • 4xx: Client Side Error
    • 400 Bad Request
    • 401 Not authorized
    • 403 Forbidden
    • 404 Not Found
  • 5xx: Server Side Error
    • 500 Internal Server Error
    • 501 Not Implemented
    • 1xx - Hold On
    • 2xx - Done, here you have
    • 3xx - Leave, go to another place
    • 4xx - You incorrectly did something
    • 5xx - I incorrectly did something

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser