HTTP
-
Upload
tricode -
Category
Technology
-
view
342 -
download
1
Transcript of HTTP
![Page 1: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/1.jpg)
HTTPHypertext Transfer Protocol
Tricode Professional Services
www.tricode.nl
25-06-2010
Marcel Blok
![Page 2: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/2.jpg)
Index
Introduction
Message format
Methods
Status codes
Headers
General headers
Request headers
Response headers
Entity headers
Entities
Chunked transfer
![Page 3: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/3.jpg)
Introduction
![Page 4: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/4.jpg)
The Hypertext Transfer Protocol (HTTP) began as an extremely basic protocol.
It was designed to do just one thing: allow a client to send a simple request for a hypertext file and receive it back from the server.
![Page 5: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/5.jpg)
Modern HTTP remains at its heart a straight-forward request/reply protocol, but now includes many new features and capabilities to support the growing size of the World Wide Web.
![Page 6: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/6.jpg)
Basic communication consists of a request message sent by a client to a server, which returns a response back to the client.
![Page 7: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/7.jpg)
Since HTTP/1.1 we have persistent connections.Multiple requests to the same server use the same TCP connection.
![Page 8: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/8.jpg)
Message format
![Page 9: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/9.jpg)
All HTTP messages are created to fit a message structure that is called the generic message format.
![Page 10: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/10.jpg)
Generic message layout:
<start-line><message-headers><empty-line>[ <message-body> ][ <message-trailers> ]
![Page 11: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/11.jpg)
HTTP Request message layout:
<start-line><general-headers><request-headers>[ <entity-headers> ]<empty-line>[ <message-body> ][ <message-trailers> ]
![Page 12: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/12.jpg)
GET /index.html HTTP/1.1Date: Wed, 23 Jun 2010 13:27:42 CETConnection: closeHost: www.somesite.comFrom: [email protected]: text/html, text/plainUser-Agent: Mozilla/4.0 (Windows 98; U)
(empty body)
general headers
request headers
start line
![Page 13: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/13.jpg)
General headers refer to the message itself and are used to control the processing or provide extra info.
Request headers convey more details about the request and provide info about how the request is handled.
Entity headers describe the entity contained in the message body.
![Page 14: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/14.jpg)
HTTP Response message layout:
<start-line><general-headers><response-headers>[ <entity-headers> ]<empty-line>[ <message-body> ][ <message-trailers> ]
![Page 15: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/15.jpg)
HTTP/1.1 200 OKDate: Wed, 23 Jun 2010 13:27:43 CETConnection: closeServer: Apache/1.3.27Accept-Ranges: bytesContent-Type: text/htmlContent-Length: 170Last-Modified: Mon, 17 May 2004 12:11:11
<html><head><title>Test</title></head><body><p>test</p></body></html>
general headers
response headers
start line
body
entityheaders
![Page 16: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/16.jpg)
Methods
![Page 17: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/17.jpg)
All client/server protocols provide a way for the client to prompt the server to take action,generally by having the client give the server a series of commands.
![Page 18: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/18.jpg)
HTTP does not have commands but rather a fixed set of methods that can be applied to any thinkable resource.
![Page 19: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/19.jpg)
GET, POST, PUT, DELETE
TRACE, HEAD, OPTIONS
![Page 20: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/20.jpg)
PUT is placing or replacing a resource at a given location.
PUT is idempotent: it has no side effects. You may repeat it and the result is the same.
![Page 21: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/21.jpg)
POST is merely sending data to a resource location. It can be handled by the server in anyway it wants. It may store the data privately. It may store it at the current location. It may update many resources. It may self destruct.
![Page 22: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/22.jpg)
Status codes
![Page 23: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/23.jpg)
Each HTTP response includes both a numeric status code and a text reason phrase, both of which indicate the disposition of the corresponding client request.
![Page 24: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/24.jpg)
1xx Informational message2xx Success3xx Redirection4xx Client error5xx Server error
![Page 25: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/25.jpg)
Headers
![Page 26: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/26.jpg)
The limited amount of methods may give the impression that HTTP is quite limited. But much of the functionality is implemented by the message headers.
![Page 27: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/27.jpg)
General headers
![Page 28: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/28.jpg)
Cache-Control, Connection, Date, Pragma, Transfer-Encoding, Upgrade, Via and Warning aresome of the HTTP general headers.
![Page 29: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/29.jpg)
Example
Cache-Control: no-storeTransfer-Encoding: chunkedUpgrade: IRC/6.9Via: 1.0 myproxy, 1.1 where.com
![Page 30: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/30.jpg)
Request headers
![Page 31: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/31.jpg)
Accept, Accept-Charset, Accept-Encoding, Accept-Language, Authorization, Expect, From,Host, If-Match, If-Modified-Since, If-None-Match, If-Range, If-Unmodified-Since, Max-Forwards,Referer, User-Agent
are some of the HTTP request headers.
![Page 32: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/32.jpg)
Example
Accept: audio/*; q=0.2, audio/basic Accept-Encoding: compress, gzipFrom: [email protected]: www.some.orgReferer: http://www.tst.org/at/1.html User-Agent: Mozilla/4.0
![Page 33: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/33.jpg)
Conditional GET example
GET /someurl HTTP/1.1If-Modified-Since: Wed, 23 Jun 2010 13:27:43 CET
HTTP/1.1 304 NOT MODIFIED
![Page 34: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/34.jpg)
Secure GET example
GET /someurl HTTP/1.1Authorization: GOOG1 GOC7F:Y9ts=
HTTP/1.1 401 UNAUTHORIZEDWWW-Authenticate: GOOG1
![Page 35: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/35.jpg)
Response headers
![Page 36: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/36.jpg)
Accept-Ranges, Age, ETag, Location, Proxy-Authenticate, Retry-After, Server, Vary, WWW-Authenticate are some of the HTTP response headers.
![Page 37: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/37.jpg)
Example
Age: 3356ETag: “1fd32ada-asd-qra8as”Server: CERN/3.0 libwww/2.17WWW-Authenticate: GOOG1
![Page 38: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/38.jpg)
Conditional GET example (2)
GET /someurl HTTP/1.1If-None-Match: “1fd32ada-asd-qra8as”
HTTP/1.1 304 NOT MODIFIED
![Page 39: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/39.jpg)
Conditional PUT example
PUT /someurl HTTP/1.1If-Match: “1fd32ada-asd-qra8as”
HTTP/1.1 412 PRECONDITION FAILED
![Page 40: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/40.jpg)
Entity headers
![Page 41: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/41.jpg)
Entity headers describe the nature of the entity in the message body, including its type, language and encoding, to facilitate the proper processing and/or presentation of the entity by the device receiving it.
![Page 42: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/42.jpg)
Allow, Content-Encoding, Content-Language, Content-Length, Content-Location, Content-MD5, Content-Range, Content-Type, Expires, Last-Modified are some of the HTTP entity headers.
![Page 43: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/43.jpg)
Example
HEAD /someurl HTTP/1.1
HTTP/1.1 200 OKLast-Modified: Wed, 23 Jun 2010 13:27:43 CET
![Page 44: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/44.jpg)
Entities
![Page 45: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/45.jpg)
While HTTP is naturally associated with hypertext, its messages can transport a large variety of different types of files, including images, audio, video and much more.
![Page 46: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/46.jpg)
To indicate the type of entity contained in an HTTP message, its sender must identify its media type and subtype. This is done using the HTTP Content-Type header, which was borrowed from the Multipurpose Internet Mail Extensions (MIME) specification.
![Page 47: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/47.jpg)
Even though HTTP borrows several concepts and header types from MIME, the protocol is not MIME-compliant.
![Page 48: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/48.jpg)
Content encoding tells something about the encoding of the entity.
Transfer-encoding tells something about the entire HTTP message, and may change from hop to hop.
![Page 49: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/49.jpg)
Chunked transfer
![Page 50: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/50.jpg)
Since HTTP/1.1 uses persistent connections that allow multiple requests and responses to be sent over a TCP connection, clients and servers need some way to identify where one message ends and the next begins.
![Page 51: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/51.jpg)
The easiest way is to send the Content-Length header with the message size. But for dynamic content you may not know this in advance. In this case you can use chunked transfer encoding.
![Page 52: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/52.jpg)
chunked message body:
<chunk-1-length><chunk-1-data><chunk-2-length><chunk-2-data>...0<message-trailers>
![Page 53: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/53.jpg)
HTTP/1.1 200 OKDate: Mon, 22 Mar 2004 11:15:03 GMTContent-Type: text/htmlContent-Length: 129Expires: Sat, 27 Mar 2004 21:12:00 GMT
<html><body><p>The file you requested is 3,400 bytes long and was last modified: Sat, 20 Mar 2004 21:12:00 GMT.</p></body></html>
![Page 54: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/54.jpg)
HTTP/1.1 200 OKDate: Mon, 22 Mar 2004 11:15:03 GMTContent-Type: text/htmlTransfer-Encoding: chunkedTrailer: Expires
29<html><body><p>The file you requested is 53,40023bytes long and was last modified: 1dSat, 20 Mar 2004 21:12:00 GMT13.</p></body></html>0Expires: Sat, 27 Mar 2004 21:12:00 GMT
![Page 55: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/55.jpg)
More…?
![Page 56: HTTP](https://reader033.fdocuments.in/reader033/viewer/2022060111/55645d60d8b42acd408b474a/html5/thumbnails/56.jpg)
• Content negotiation
• Cache, cache, cache!• HTTPS
• Cookies
• Same Origin Policy
• Cross-Origin Resource Sharing