HTTP and Web Technologies Flashcards
What is HTTP?
Hyper Text Transfer Protocol (HTTP) is an application layer protocol which allows for data communication for World Wide Web.
It defines how messages should be formatted and transmitted and what actions should browsers take in response to various commands.
What is HTTPS?
Hyper Text Transfer Protocol Secure (HTTPS) is the extension of HTTP. It is used for secure communication as it encrypts all message contents, including HTTP headers and request/response data.
In HTTPS, the underlying communication protocol (TCP) is encrypted using TLS (Transport Layer Security).
HTTPS promotes:
- authentication of accessed websites
- protection of privacy and integrity of exchanged data while in transit
and provides protection against:
- man in the middle attack
- eavesdropping
- data tampering
What is client and server?
In terms of networking, client is the entity initiating a request for data/service and server is the entity providing the data/service.
What is a stateless and stateful protocol?
- Stateless protocol is the one in which state of client (session data, identity, status etc) is not stored by server and every request from client is treated as an independent request.
For eg. IP, HTTP - Stateful protocol is the one in which server has to maintain the state of client.
For eg. TCP, BGP
Give examples of stateless protocol.
IP and HTTP
Give examples of stateful protocol.
TCP and BGP
Give the default ports for:
- HTTP
- HTTPS
- echo
- FTP data
- FTP control
- SSH
- SMTP
- DHCP server
- DHCP client
- SQL server
- Telnet
- POP3
- DNS
- 80
- 443
- 7
- 20
- 21
- 22
- 25
- 67
- 68
- 1433
- 23
- 110
- 53
How does server store state when HTTP, the communication protocol, is stateless?
HTTP is layered on top of TCP, the transmission/connection protocol, which itself is stateful.
In addition to this, the server uses cookies, a session management method, to store the state.
What is a port?
IP addresses identify the network but cannot identify the services (SMTP/HTTP/FTP) on that network. TCP/UDP extend the IP addresses by providing the 2-byte address of these services, called port.
What is an HTTP session?
It is the sequence of network request-response transactions for a single client and consists of three phases:
- Client establishes a TCP connection.
- Client sends a request
- Server processes the request, sending back status code and data.
Explain the request-response pair.
The HTTP communication sent by client is termed as request, which contains startline (HTTP verb followed by URI followed by HTTP version), header (acceptable data formats/size/languages), a blank line and optional body.
The HTTP reply by server to the request by client is termed as response, which contains status line (HTTP status code followed by status text followed by HTTP version), header (format/size/langague of data) and optional body.
What is the current version of HTTP and what are its advantages over previous version?
Current version is HTTP/2.
Advantages of HTTP/2 over HTTP/1.1:
- data compression of header
- parallel loading of page elements (image, video, text)
- request prioritization
What is a URL? Explain the structure of URL.
Uniform Resource Locator (URL) is the web address of a web resource specifying its uniform location in computer network.
For a URL
https://www.hellothere.com:1234/catalogue/home?location=sydney&budget=10000
- https:// is the protocol
- www.hellothere.com is the host
- 1234 is the port number
- catalogue/home is resource path
- location=sydney&budget=10000 is the query.
What is a URI? Whats the difference between URI and URL?
Uniform Resource Identifier (URI) is a compact sequence of characters that identify a web resource, but cannot locate it.
URLs can identify and locate a resource and hence are URIs. This makes all URLs URIs but vice versa is not true.
For eg. name of a person is URI as it can identify it but cannot locate it. Address of a person is URL and URI as it can locate and identify it.
What is URN? Whats the difference between URL, URI and URN?
Uniform Resource Name (URN) is used to identify a resource by unique name but not locate it. It is in the form of urn:isbn:n-nn-nnnnnn-n.
URLs identify and locate a resource whereas URNs only identiy the resource by a unique name. Both URLs and URNs are URIs.
What are the HTTP verbs?
The action that a client would like to perfom is termed as HTTP verb.
GET, POST, PUT, DELETE, HEAD, CONNECT, PATCH are some of the verbs.
Explain idempotent methods.
A method is idempotent if multiple requests of that method can be made without changing the result beyond initial application.
GET, PUT, HEAD, PATCH, DELETE are idempotent methods but POST is not.
What is HTTP GET?
It is used to retrieve a resource from server. It can send limited data which is appended to the URL. As this displays the username and password, GET is unsecure. Ex. GET /dept/class HTTP/1.1
What is HTTP POST?
It is used to send data to the server to create new resources through a separate body section. Ex. POST /home/class HTTP/1.1
What is HTTP DELETE?
It is used to delete the data on server.
Ex. DELETE /home/class HTTP/1.1
What is HTTP PUT?
It is used to either entirely replace existing data or create new resource on server.
Ex. PUT /home/class HTTP/1.1
What is HTTP HEAD?
It is used to request headers that are generally sent with GET which can be checked before downloading a large resource.
Ex. HEAD /home/class
What is HTTP PATCH? What is the difference between HTTP PUT and HTTP PATCH?
HTTP PATCH is used to modify portions of already existing data on server. HTTP PUT replaces entire resource with the new data. Ex. PATCH /home/class HTTP/1.1
What is HTTP CONNECT?
Used by client to start two-way communication with requested server only when it knows it talks to proxy and the final URI begins with https://.
CONNECT www.google.com:443 HTTP/1.1
asks proxy to open a raw TCP connection to google and to repeat the data over that connection without any interpretation.
The intent of connect is to allow end-to-end encrypted TLS session, so that the data is unreadable to a proxy.
Once the connection has been established by the server, the Proxy server continues to proxy the TCP stream to and from the client.
What is HTTP TRACE?
It is used to retrieve the hops that a request takes to round trip from server and is used for diagnostic purposes.
Ex. TRACE /home/class
What is HTTP OPTIONS?
HTTP OPTIONS method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.
The request can be either
- OPTIONS /catalogue/home HTTP/1.1 or
- OPTIONS * HTTP/1.1
The client can send a URI for OPTIONS method or an asterisk (*) to refer to entire server.
Minimally, the response should be a 200 OK and have an Allow header with a list of HTTP methods that may be used on this resource.
It is used mostly by APIs to describe to user what he/she is allowed to do with each resource exposed by their endpoints.
What is the status code?
Status code provides the status of serverâs processing of the request from client. The status codes starting with
1xx: information message (request is received by server)
2xx: request processing successful
3xx: redirection
4xx: client error
5xx: server error
What is HTTP status 100?
Continue
server has received the request headers and the client should proceed to send the request body.
What is HTTP status 101?
Switching protocols
What is HTTP status 200?
OK
request was processed successfully and response was sent
What is HTTP status 201?
Created
New resource was created by request on server
What is HTTP status 202?
Accepted
the request has been accepted for processing
What is HTTP status 204?
No Content
the request was processed successfully but does not contain any data
What is HTTP status 300?
Multiple choices
multiple options for the resource from which the client may choose (via agent-driven content negotiation)
What is HTTP status 301?
Moved permanently
the new location of resource is given in the Location option inside response header
What is HTTP status 304?
Not modified
The resource is not modified and client should use cached copy
What is HTTP status 400?
Bad request
server did not understand the request due to invalid syntax/too large size
What is HTTP status 401?
Unauthorized
need to perform authentication before accessing the resource
What is HTTP status 403?
Forbidden
similar to 401 except reauthentication will make no difference. The access is permanantly forbidden and tied to the application logic, such as insufficient rights to a resource (for eg, creating a duplicate record where only one is allowed)
What is HTTP status 404?
Page Not Found
What is HTTP status 405?
Method Not Allowed
requested method is not supported for resource such as PUT request on a read-only resource.
What is HTTP status 406?
Not Acceptable
The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request (related to content negotiation)
What is HTTP status 407?
Proxy Authentication Required
The client must first authenticate itself with the proxy
What is HTTP status 408?
Request Timeout
request took longer than the server was prepared to wait
What is HTTP status 410?
Gone
resource requested is no longer available and will not be available again
What is HTTP status 413?
Payload Too Large
The requested resource is too large for the server to handle
What is HTTP status 414?
URI Too Long
The URI provided was too long for the server to process
What is HTTP status 415?
Unsupported Media Type
The requested resource has a media type which does not match Content-Type or Content-Encoding values of request.
What is HTTP status 440?
Login Time-out
The clientâs session has expired and must log in again.
What is HTTP status 500?
Internal server error
What is HTTP status 501?
Not implemented
The server does not yet support the functionality
What is HTTP status 502?
Bad Gateway
Indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server, requires a fix by the web server or the proxies you are trying to get access through.
What is HTTP status 503?
Service Unavailable
Common causes are a server that is down for maintenance or that is overloaded. This response should be used for temporary conditions and the Retry-After HTTP header should contain the estimated time for the recovery of the service.
What is HTTP status 504?
Gateway Timeout
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server
What is HTTP status 505?
HTTP Version Not Supported
The server does not support the HTTP protocol version used in the request
What is ETag?
Entity Tag (ETag) is an identifier assigned by server to a specific version of resource.
When a server receives a request, it sends the resource with its ETag value. If the client decides to cache the resource, the ETag value is also stored.
When the client requests for same resource again, the request is sent with ETag value of cached version. If it matches with ETag value of resource version on server, then 304 Not Modified status is sent to the client, asking client to fetch cached copy.
If it does not match, server sends new version of resource.
What is the âTransfer-Encoding: chunkedâ header?
It is used to break the response into smaller parts allowing for streaming of data instead of one big payload.
What protocol layers HTTP connection is made on?
HTTP connection is made over TCP which is over IP.
What protocol layers HTTPS connection is made on?
HTTPS connection is made over TLS/SSL which is over TCP followed by IP.
Explain persistent connections in HTTP/1.1.
In HTTP/1.0, all connections were closed after single transaction. If client wants 3 resources, then client needs to send 3 requests, which can introduce network traffic and delay.
HTTP/1.1 supports long-lived connections that stay open until client explicitly closes them. These are termed as persistent connections and they are default now.