Docsity

Understanding HTTP: Protocol, Basic Operation, and Features, Slides of Information Security and Markup Languages

Partial preview of the text

Download Understanding HTTP: Protocol, Basic Operation, and Features and more Slides Information Security and Markup Languages in PDF only on Docsity!

HyperText Transfer Protocol

HTTP v1.

What is HTTP?

  • Protocol for transfer of data between Web

servers and Web clients (browsers).

  • Popular Web servers:
    • Apache HTTPD
    • JBoss
    • Tomcat
  • Popular Web clients:
    • Firefox
    • Opera
    • wget
  • Defined formally by IETF as RFC2616.

Basic Operation

Client Server

Request Method URL / RelativeURL Request Headers Request Body

Protocol Version Status Code Response Headers Response Body

Example HTTP Communication

  • ClientServer:

GET / HTTP/1. Host: www.cs.uct.ac.za

  • ServerClient:

HTTP/1.1 200 OK Content-type: text/html Content-length: 1024

Really old webpage!

Amaya

Tim Berners-Lee’s WWW Vision

  • The WWW is meant to be a place for

accessing and authoring content, not just the

former.

  • Amaya is W3C’s experimental 2-way browser

that works with their 2-way server Jigsaw.

  • Is access more important than content

creation? Why (not)?

HTTP Response

  • Format:

Status^ –^ HTTPVersion StatusCode Reason Reason Description

200 OK Successful request 206 Partial Content Successful request for partial content

301 Moved Permanently Resource has been relocated

304 Not Modified Conditional GET but resource has not changed 400 Bad Request Request not understood 403 Forbidden Access to resource not allowed 404 Not Found URI/resource not found on server

500 Internal Server Error Unexpected error

HTTP Headers

  • Accept: Indicates which data formats are acceptable.
    • Accept: text/html, text/plain
  • Content-Language: Language of the content
    • Content-Language: en
  • Content-Length: Size of message body
    • Content-Length: 1234
  • Content-Type: MIME type of content body
    • Content-Type: text/html
  • Date: Date of request/response
    • Date: Tue, 15 Nov 1994 08:12:31 GMT
  • Expires: When content is no longer valid
    • Expires: Tue, 15 Nov 1994 08:12:31 GMT
  • Host: Machine that request is directed to
    • Host: www.cs.uct.ac.za
  • Location: Redirection to a different resource
    • Location: http://myserver.org/
  • Retry-After: Indicates that client must try again in future
    • Retry-After: 120

Non-static content

  • HTTP can support content that is not static.
  • For a GET request, data is appended to the

request – for a POST request, data is

contained in the request body.

  • Responses are generated by a piece of

software and are similar to the non-static

version.

Common Gateway Interface

  • Common Gateway Interface (CGI) defines how parameters are

passed to Web applications.

  • For a GET request, the URL contains
    • http://host:port/path/file?var1=value1&var2=value2&var3=value3...
    • These are called URL-encoded parameters.
  • The part beyond ‘?’ is passed in the environment of the Web

application as a QUERY_STRING.

  • The application interprets the QUERY_STRING, generates an

HTTP response and writes it to stdout, with at least a Content- type header.

  • HTML forms generate GET requests that can easily be

converted to support CGI.

CGI POST

  • GET cannot handle file uploads.
  • File uploads are handled as Multipart-MIME

messages sent from the client to the server.

Content-Disposition: form-data; name="var1" something

Content-Disposition: form-data; name="var2"; filename="testpost.html“ Content-Type: text/html

-----------------------------41184676334--

recursive example

if you fill in the form embedded here, this is the data that gets sent to the server

Not-So-Common Gateway Interfaces

  • Instead of QUERY_STRING and stdin and

stdout for data,

  • Java servlets use methods to acquire

parameters and output data.

  • PHP defines global variables for GET/POST

query parameters.