http and apache roy t. fielding ebuilt, inc. the apache software foundation [email protected]
TRANSCRIPT
![Page 2: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/2.jpg)
Overview
HTTP Basics Apache httpd architecture
• Connection management (listening)• Request Reading• Finding a representation• Conditional request evaluation• Response Writing• Connection management (closing)
Future Improvements waka/2.0
![Page 3: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/3.jpg)
Web architecture
• Layered-client-server• Uniform “resource” interface
– Simple, but powerful– Semantics are visible to intermediaries
• HTTP extends interface across network
HTTP Basics
![Page 4: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/4.jpg)
HTTP Message Syntax
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n\r\n
HTTP/1.1 200 OK\r\nDate: Thu, 09 Mar 2000 15:40:09 GMT\r\nServer: Apache/1.3.12\r\nContent-Type: text/html\r\nContent-Language: en\r\nTransfer-Encoding: chunked\r\nEtag: “a797cd-465af”\r\nCache-control: max-age=3600\r\nVary: Accept-Language\r\n
\r\n 4090\r\n
<HTML><HEAD> …
![Page 5: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/5.jpg)
Request Envelope
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n
\r\n
![Page 6: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/6.jpg)
Request Control Data
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n
\r\n
![Page 7: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/7.jpg)
Request Metadata
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n
\r\n
![Page 8: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/8.jpg)
Request Metadata
POST /nasdaq/trade.php HTTP/1.1\r\nHost: www.datek.com\r\nUser-Agent: poseur/1.0 libwww/3.1\r\n
Content-type: www/x-urlencoded\r\n
Content-length: 58\r\n
\r\n
Ticker=LNUX&quantity=140&action=sell
&type=limit&amt=298.00
![Page 9: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/9.jpg)
Request Data
POST /nasdaq/trade.php HTTP/1.1\r\nHost: www.datek.com\r\nUser-Agent: poseur/1.0 libwww/3.1\r\n
Content-type: www/x-urlencoded\r\n
Content-length: 58\r\n
\r\n
Ticker=LNUX&quantity=140&action=sell
&type=limit&amt=298.00
![Page 10: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/10.jpg)
Request Data
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n
\r\n
![Page 11: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/11.jpg)
Response Envelope
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n\r\n
HTTP/1.1 200 OK\r\nDate: Thu, 09 Mar 2000 15:40:09 GMT\r\nServer: Apache/1.3.12\r\nContent-Type: text/html\r\nContent-Language: en\r\nTransfer-Encoding: chunked\r\nEtag: “a797cd-465af”\r\nCache-control: max-age=3600\r\nVary: Accept-Language\r\n
\r\n 4090\r\n
<HTML><HEAD> …
![Page 12: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/12.jpg)
Response Control Data
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n\r\n
HTTP/1.1 200 OK\r\nDate: Thu, 09 Mar 2000 15:40:09 GMT\r\nServer: Apache/1.3.12\r\nContent-Type: text/html\r\nContent-Language: en\r\nTransfer-Encoding: chunked\r\nEtag: “a797cd-465af”\r\nCache-control: max-age=3600\r\nVary: Accept-Language\r\n
\r\n 4090\r\n
<HTML><HEAD> …
![Page 13: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/13.jpg)
Response Metadata
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n\r\n
HTTP/1.1 200 OK\r\nDate: Thu, 09 Mar 2000 15:40:09 GMT\r\nServer: Apache/1.3.12\r\nContent-Type: text/html\r\nContent-Language: en\r\nTransfer-Encoding: chunked\r\nEtag: “a797cd-465af”\r\nCache-control: max-age=3600\r\nVary: Accept-Language\r\n
\r\n 4090\r\n
<HTML><HEAD> …
![Page 14: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/14.jpg)
Response Data
GET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n\r\n
HTTP/1.1 200 OK\r\nDate: Thu, 09 Mar 2000 15:40:09 GMT\r\nServer: Apache/1.3.12\r\nContent-Type: text/html\r\nContent-Language: en\r\nTransfer-Encoding: chunked\r\nEtag: “a797cd-465af”\r\nCache-control: max-age=3600\r\nVary: Accept-Language\r\n
\r\n 4090\r\n
<HTML><HEAD> …
![Page 15: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/15.jpg)
Overview
HTTP Basics Apache httpd architecture
• Connection management (listening)• Request Reading• Finding a representation• Conditional request evaluation• Response Writing• Connection management (closing)
Future Improvements waka/2.0
![Page 16: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/16.jpg)
httpd Initialization
httpd core• apache-2.0/src/main/*.c
Initiate program• http_main.c
Read configuration files• http_config.c, http_core.c
Start logging• http_log.c
Start server listeners (MPM)• apache-2.0/src/modules/mpm/*
![Page 17: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/17.jpg)
Connection management
Listening and Accept• mpm/prefork/prefork.c• mpm/mpmt_pthread.c• …
Connection set-up• src/main/http_connection.c• Modular hooks for protocol independence• ap_process_http_connection()
– Calls ap_read_request()and we are finally at the level of HTTP
![Page 18: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/18.jpg)
Request Reading
src/main/http_protocol.cGET /Test/hello.html HTTP/1.1\r\nHost: kiwi.ics.uci.edu:8080\r\nUser-Agent: GET/7 libwww-perl/5.40\r\n\r\n
Request Line• read_request_line(r)
Header fields• get_mime_headers(r)
Host determination• http_vhost.c
![Page 19: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/19.jpg)
Request Processing
src/main/http_request.c Access control
• Directory walk• Location walk• File walk
Handler selection• Field pre-processing• Content Handler
![Page 20: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/20.jpg)
Request Body
src/main/http_protocol.c Declaration
• ap_setup_client_block(r, policy)
Test• ap_should_client_block(r)
Read until done• ap_get_client_block(r, …)
Shortcut• ap_discard_request_body(r)
![Page 21: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/21.jpg)
Finding a representation
Each content handler is responsible for associating the URI with a resource and applying the method, returning a representation as the response
Redirection Negotiation Subrequests Errors
![Page 22: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/22.jpg)
Conditional request evaluation
Conditional requests modify method processing depending on the current state of the resource representation • Last-Modified• Etag
Cache validation• If-Modified-Since• If-Nonematch
Prerequisites• If-Match• If-Unmodified-Since• Range-If• If
![Page 23: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/23.jpg)
Response WritingHTTP/1.1 200 OK\r\nDate: Thu, 09 Mar 2000 15:40:09 GMT\r\nServer: Apache/1.3.12\r\nContent-Type: text/html\r\nContent-Language: en\r\nTransfer-Encoding: chunked\r\nEtag: “a797cd-465af”\r\nCache-control: max-age=3600\r\nVary: Accept-Language\r\n
\r\n 4090\r\n
<HTML><HEAD> …
Status code and reason phrase Header fields Body
![Page 24: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/24.jpg)
Response Writing
Status code and reason phrase• r->status• r->status_line || status_lines[idx]
Header fields• r->headers_out• r->err_headers_out
Headers set by modules• mod_expires.c• mod_headers.c
– Header set Author “John Q. Public”
![Page 25: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/25.jpg)
Send Body
Body• File• Buffer• IO-layer
Transfer-encoding• Length delimited• Chunked• Connection terminated
![Page 26: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/26.jpg)
Connection management
Persistent connections• The big hairy if• ap_set_keepalive(r)
Connection tear-down• Lingering close
![Page 27: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/27.jpg)
Overview
HTTP Basics Apache httpd architecture
• Connection management (listening)• Request Reading• Finding a representation• Conditional request evaluation• Response Writing• Connection management (closing)
Future Improvements waka/2.0
![Page 28: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/28.jpg)
Future Improvements
Configurable protocol elements• Methods, status codes, field names
Tokenized field manipulation• Field name -> token• Field value -> linked list
Streaming IO Layers• Stacked protocol manipulation• Separate streams for data and metadata
– Token streams
• Bucket brigades– Strings, Files, Cache handles
![Page 29: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/29.jpg)
waka/2.0
A replacement for HTTP/1.x• Emphasizes the REST architectural style• Ideas from Spero’s HTTP-ng and W3C HTTP-NG
Packet streams• Control, meta-metadata, metadata, data• Prioritized bandwidth usage
Self-descriptive• All syntax an extensible standard• All cache rules in response• Simple quality of service indicators• Transport independent
Tokenized• Optimized for memory transfer
![Page 30: HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation fielding@apache.org](https://reader035.vdocument.in/reader035/viewer/2022062618/55142e78550346dd488b5e88/html5/thumbnails/30.jpg)
Questions?
Where to go for more information• http://www.ics.uci.edu/pub/ietf/http/• http://www.ics.uci.edu/~fielding/talks/
Places to see:• Front Door www.apache.org• Developer Notes dev.apache.org• PR Database bugs.apache.org• Apache Week www.apacheweek.com• O’Reilly Net www.oreilly.net/apache/