SEC 260
Web and Applications Security
4- HTTP Messages, Status and Headers
HTTP Messages Overview
2
Parts of a HTTP Message
3
Client
Server
HTTP/1.0 200 OK
Content-type: text/plain�Content-length: 19
Hi! I am a message
Start Line
Headers
Body
4
HTTP Message Syntax
Client
Server
HTTP/1.0 200 OK�Content-type: image/gif�Content-Length:8572
GET /specials/saw-blade.gif HTTP/1.0�Host: www.joes-hardware.com
HTTP request contains the command and the URL
HTTP response contains the result of the transaction
5
Start Lines
Client
Server
HTTP/1.0 200 OK
GET /specials/saw-blade.gif HTTP/1.0
6
Start Lines: Methods
Method | Description | Message body? |
GET | Get a document from the server. | No |
HEAD | Get just the headers for a document from the server. | No |
POST | Send data to the server for processing. | Yes |
PUT | Store the body of the request on the server. | Yes |
TRACE | Trace the message through proxy servers to the server. | No |
OPTIONS | Determine what methods can operate on a server. | No |
DELETE | Remove a document from the server. | No |
7
Response Start Lines: Status Codes
Overall Range | Defined Range | Category |
100-199 | 100-101 | Informational |
200-299 | 200-206 | Successful |
300-399 | 300-305 | Redirection |
400-499 | 400-415 | Client Error |
500-599 | 500-505 | Server Error |
Tell the client what happened:
8
HTTP Headers
9
HTTP Request
Everything after the GET is a Header Field
10
HTTP Response
Everything after the Status is a Header. Until DocType which starts the Content
HTTP/1.x 200 OK
Date: Sat, 28 Nov 2017 04:36:25 GMT
Server: LiteSpeed
Connection: close
Expires: Sat, 28 Nov 2017 05:36:25 GMT
Cache-Control: max-age=3600, public
Content-Type: text/html; charset=UTF-8
Last-Modified: Sat, 28 Nov 2017 03:50:37 GMT
Content-Encoding: gzip
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Top 20+ MySQL Best Practices - Nettuts+</title>
<!-- ... rest of the html ... -->
11
HEAD Method
HEAD: Retrieve Header Information
12
HEAD Method
HEAD: Retrieve Header Information
With this method, the browser can:
Usage:
13
Response Headers
Host:�
14
Response Headers
User Agent:
15
Request: Other Headers
16
Response Headers: Cache-Control
17
Response Headers: Content-Type
18
Response Headers: Last-Modified
Last-Modified: Includes the date the page was last modified
Used in conjunction with the If-Modified-Since Request Header
Class Activity
Telnet & HTTP
HTTP Status Code
19