HTTP Protocol Basics Flashcards
HTTP (Hypertext Transfer Protocol)
- clear-text
- most used app protocol
- client-server
- transfers web pages and web app data
- can be intercepted
- does not provide strong authentication between parties
HTTP first step
client (usually web browser) connects to web server (MS IIS r Apache HTTP Server)
HTTP second step
client and server exchange messages (request & response)
How is HTTP related to TCP protocol?
It works on top of TCP.
- TCP connection is made
- client sends request
- server processes request
- server send back answer w/ status code and data
What is the format of an HTTP message?
- Headers\r\n
- \r\n
- Message Body\r\n
How do you end lines in HTTP?
\r : carriage return
\n: newline
What is the format of an HTTP header field?
Header-name: header value
HTTP verb
- aka: request method
- state the type of request
GET request
used when opening web resources
After the HTTP verb, there is a path. What does the path do?
tells server which resources the browser is asking for
After the HTTP verb and path, there is the protocol version. What is the protocol version?
tells server how to communicate with the browser
What is the structure of the first line of an HTTP request?
HTTP VERB, path, protocol version
What does the HTTP Request Host header field specify?
- it specifies the internet hostname and port number of the resource being requested
- tells server which site client is asking for
URI
identifies a specific resuorce: page, book, document
URL
- type of URI
- tells you how to access the resource: HTTPS, FTP
User-Agent
tell server what client software & version is issuing the request: Firefox, Safari, Chrome, etc
Accept header field
specifies which document type it is expecting in response
Accept-Encoding
restricts content encoding, not the content itself.
• for example, the browser will accept two types of compression if read “: gzip, deflate”
Connection header
allows sender to specify options that are desired for that particular connection
• for example, future comms w/ server will reuse current connection if “keep-alive”
HTTP Response: Status-Line
- protocol version (HTTP 1.1)
- status code (200)
- relative textual meaning (OK)
Status Code: 200
- OK
- resource found
Status Code: 301
- Moved Permanently
- resource has been assigned a new permanent URI
Status Code: 302
- Found
- temporarily under another URI
Status Code: 403
- Forbidden
- client doesn’t have enough privileges, server refuses to fulfill request
Status Code: 404
- Not Found
- server cannot find a resource matching the request
Status Code: 500
- Internal Service Error
- server does not support the functionality required to fulfill request
Cache-Control header
- server informs client about cached content
Content-Type header
lets client know how to interpret body of message
Content-Encoding header (for HTTP response)
extends content type - for example, “gzip” would mean message body is compressed with gzip
Server header
contains the header of the server that generated the content
ex: “Apache/2.2.15 (CentOS)
Content-Length header
indicates length of bytes of the message body