Tuesday, October 04, 2005

HTTP Essentials

Digest from "HTTP Essentials" By Stephen A.Thomas

* URI
http://user:passwd@www.example.com:80/html.filepath/filename.html?query1=1#Fragment

* TCP Connection

Client ---------------> Server
1) TCP SYN
<---------------
2) TCP SYN, ACK
--------------->
3) TCP ACK (3-way handshake)

--------------->
4) HTTP Request
<---------------
5) HTTP Response

<---------------
6) TCP FIN
--------------->
7) TCP FIN, ACK

* Persistent

With persistent connections, a client can issue many HTTP requests over a single TCP connection.

* Pipelining

With Pipelining, a client dosen't have to wait for a response to one request before issuing a new request on the connection.

Client ---------------> Server
1) TCP SYN
<---------------
2) TCP SYN, ACK
--------------->
3) TCP ACK (3-way handshake)

--------------->
4.1) HTTP Request1
--------------->
4.2) HTTP Request2
<---------------
5.1) HTTP Response1
<---------------
5.2) HTTP Response2

<---------------
6) TCP FIN
--------------->
7) TCP FIN, ACK


* User Operations

GET

Client ---------------> Server
1) GET URI
<---------------
2) 200 OK, DATA (if error, return other status code.)


POST

Client ---------------> Server
1) POST URI (action URI), DATA
<---------------
2) 200 OK[, DATA] (if error, return other status code.)


PUT (File Upload)

Client ---------------> Server
1) PUT URI (where to put object), DATA
<---------------
2) 200 OK[, DATA] (if error, return other status code.)


DELETE (File Deletion)

Client ---------------> Server
1) DELETE URI (remove object), DATA
<---------------
2) 200 OK[, DATA] (if error, return other status code.)


* Behind the Scenes

OPTIONS
Discover what capabilities a server supports. Such information would let the client adjust how it interacts with the server or how it actually requests a specific object.

Client ---------------> Server
1) OPTIONS URI/*(General options)
<---------------
2) 200 OK, OPTIONS


HEAD
Just like the a GET operation, except that the server doesn't return the actual object request. It can be used to verify that an obj exists.

Client ---------------> Server
1) HEAD URI
<---------------
2) 200 OK


TRACE
Check the network path to a server.

Client ---------------> Intermediate Server ---------------> Ultimate Server
1) TRACE 2) TRACE, Via
<--------------- <---------------
4) 200 OK, message 3) 200 OK, message


* Cooperating Servers

Virtual Hosts
The 'HOST' header in HTTP 1.1 lets clients explicitly identify the Web site they are accessing, so the virtual hosting Web server can return the right content.

Client ---------------> Server --|--------- www.company1.com
1) GET /news.html |
Host:www.company1.com |--------- www.company2.com
<---------------
2) 200 OK, DATA (if error, return other status code.)


Redirection

Client ---------------> Server1
1) GET URI
<---------------
2) 301 Moved, NewURI
---------------> Server2
3) GET NewURI
<---------------
4) 200 OK

No comments: