HTTP and ApacheOverviewHTTP BasicsHTTP Message SyntaxRequest EnvelopeRequest Control DataRequest MetadataSlide 8Request DataSlide 10Response EnvelopeResponse Control DataResponse MetadataResponse DataSlide 15httpd InitializationConnection managementRequest ReadingRequest ProcessingRequest BodyFinding a representationConditional request evaluationResponse WritingSlide 24Send BodySlide 26Slide 27Future Improvementswaka/2.0Questions?HTTP and ApacheRoy T. FieldingeBuilt, Inc.The Apache Software [email protected]HTTP BasicsApache httpd architecture•Connection management (listening)•Request Reading•Finding a representation•Conditional request evaluation•Response Writing•Connection management (closing)Future Improvementswaka/2.0Web architecture•Layered-client-server•Uniform “resource” interface–Simple, but powerful–Semantics are visible to intermediaries•HTTP extends interface across networkHTTP BasicsHTTP Message SyntaxGET /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\nHTTP/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> …Request EnvelopeGET /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\nRequest Control DataGET /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\nRequest MetadataGET /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\nRequest MetadataPOST /nasdaq/trade.php HTTP/1.1\r\nHost: www.datek.com\r\nUser-Agent: poseur/1.0 libwww/3.1\r\nContent-type: www/x-urlencoded\r\nContent-length: 58\r\n\r\nTicker=LNUX&quantity=140&action=sell&type=limit&amt=298.00Request DataPOST /nasdaq/trade.php HTTP/1.1\r\nHost: www.datek.com\r\nUser-Agent: poseur/1.0 libwww/3.1\r\nContent-type: www/x-urlencoded\r\nContent-length: 58\r\n\r\nTicker=LNUX&quantity=140&action=sell&type=limit&amt=298.00Request DataGET /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\nResponse EnvelopeGET /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\nHTTP/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> …Response Control DataGET /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\nHTTP/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> …Response MetadataGET /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\nHTTP/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> …Response DataGET /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\nHTTP/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> …OverviewHTTP BasicsApache httpd architecture•Connection management (listening)•Request Reading•Finding a representation•Conditional request evaluation•Response Writing•Connection management (closing)Future Improvementswaka/2.0httpd Initializationhttpd core•apache-2.0/src/main/*.cInitiate program•http_main.cRead configuration files•http_config.c, http_core.cStart logging•http_log.cStart server listeners (MPM)•apache-2.0/src/modules/mpm/*Connection managementListening 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 HTTPRequest Readingsrc/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\nRequest Line•read_request_line(r)Header fields•get_mime_headers(r)Host determination•http_vhost.cRequest Processingsrc/main/http_request.cAccess control•Directory walk•Location walk•File walkHandler selection•Field pre-processing•Content HandlerRequest Bodysrc/main/http_protocol.cDeclaration•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)Finding a representationEach content handler is responsible for associating the URI with a resource and applying the method, returning a representation as the responseRedirectionNegotiationSubrequestsErrorsConditional request evaluationConditional requests modify method processing depending on the current state of the resource representation •Last-Modified•EtagCache validation•If-Modified-Since•If-NonematchPrerequisites•If-Match•If-Unmodified-Since•Range-If•IfResponse 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 phraseHeader fieldsBodyResponse WritingStatus code and reason phrase•r->status•r->status_line || status_lines[idx]Header fields•r->headers_out•r->err_headers_outHeaders set by modules•mod_expires.c•mod_headers.c–Header set Author “John Q. Public”Send BodyBody•File•Buffer•IO-layerTransfer-encoding•Length
or
We will never post anything without your permission.
Don't have an account? Sign up