http_protocol.c revision f261041e9d845c3e0ed9be7fefae2df2be61bfe4
f743002678eb67b99bbc29fee116b65d9530fec0wrowe/* Licensed to the Apache Software Foundation (ASF) under one or more
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg * contributor license agreements. See the NOTICE file distributed with
5c43d2fb853f84497b5ece2d414ef9484aa87e5fsf * this work for additional information regarding copyright ownership.
05a5a9c3e16f21566e1b61f4bd68025ce1b741ccjoes * The ASF licenses this file to You under the Apache License, Version 2.0
05a5a9c3e16f21566e1b61f4bd68025ce1b741ccjoes * (the "License"); you may not use this file except in compliance with
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq * the License. You may obtain a copy of the License at
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq * Unless required by applicable law or agreed to in writing, software
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq * distributed under the License is distributed on an "AS IS" BASIS,
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq * See the License for the specific language governing permissions and
4fc0f3118f25efdd3d09b1c53746e92dbcc600f0sf * limitations under the License.
c12917da693bae4028a1d5a5e8224bceed8c739dsf * http_protocol.c --- routines which directly communicate with the client.
eeb7898b9c087040d44550f8a6b1a257783c9f0ahumbedooh * Code originally by Rob McCool; much redone by Robert S. Thau
eeb7898b9c087040d44550f8a6b1a257783c9f0ahumbedooh * and the Apache Software Foundation.
88fac54d9d64f85bbdab5d7010816f4377f95bd7rjung#include "http_log.h" /* For errors detected in basic auth common
88fac54d9d64f85bbdab5d7010816f4377f95bd7rjung * support code... */
bd3f5647b96d378d9c75c954e3f13582af32c643sf#include "apr_date.h" /* For apr_date_parse_http and APR_DATE_BAD */
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf/* New Apache routine to map status codes into array indicies
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf * e.g. 100 -> 0, 101 -> 1, 200 -> 2 ...
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf * The number of status lines must equal the value of RESPONSE_CODES (httpd.h)
132ee6ac1c26d6e8953836316ba50734eefab47bsf * and must be listed in order.
fc1459657a1fde206a847f9028930725d715f8b4trawick/* The second const triggers an assembler bug on UTS 2.1.
fc1459657a1fde206a847f9028930725d715f8b4trawick * Another workaround is to move some code out of this file into another,
85eacfc96a04547ef25aabbc06440039715084c2jorton * but this is easier. Dave Dykstra, 3/31/99
68ba377fc3b124baa759662077c48077ebadb186minfrinstatic const char * const status_lines[RESPONSE_CODES] =
d776b0a2d2889ce1d13494873368f34327a2e1bbtrawick "100 Continue",
d776b0a2d2889ce1d13494873368f34327a2e1bbtrawick "101 Switching Protocols",
f4ca9f6f002fece336168a16355434ca966f96a9trawick "102 Processing",
78f94f1d06c4e6828ce04d618221e0fcecb57849humbedooh "201 Created",
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick "202 Accepted",
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick "203 Non-Authoritative Information",
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick "204 No Content",
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick "205 Reset Content",
70caa242e6b90e0d6f0fabb56b8c5c2fb51717b3jorton "206 Partial Content",
985a4368b93c3e9171a57897ad9454c8dbf4cdf6jorton "207 Multi-Status",
70caa242e6b90e0d6f0fabb56b8c5c2fb51717b3jorton "300 Multiple Choices",
109e2a09790de3fb315d36d6232a14ab66c8eb0ahumbedooh "301 Moved Permanently",
109e2a09790de3fb315d36d6232a14ab66c8eb0ahumbedooh "302 Found",
109e2a09790de3fb315d36d6232a14ab66c8eb0ahumbedooh "303 See Other",
74e7a30182af5e68f14ccb8d57918b22b982db8bhumbedooh "304 Not Modified",
74e7a30182af5e68f14ccb8d57918b22b982db8bhumbedooh "305 Use Proxy",
74e7a30182af5e68f14ccb8d57918b22b982db8bhumbedooh "306 unused",
10961a2f60207cb873d889bb28b1f0ef707a4311humbedooh "307 Temporary Redirect",
10961a2f60207cb873d889bb28b1f0ef707a4311humbedooh "400 Bad Request",
0448378b899e8df0c060360f17c0af692adf17bchumbedooh "401 Authorization Required",
0448378b899e8df0c060360f17c0af692adf17bchumbedooh "402 Payment Required",
0448378b899e8df0c060360f17c0af692adf17bchumbedooh "403 Forbidden",
60a765cccbd3f3b5997b65b0034220c79f78369etrawick "404 Not Found",
60a765cccbd3f3b5997b65b0034220c79f78369etrawick "405 Method Not Allowed",
60a765cccbd3f3b5997b65b0034220c79f78369etrawick "406 Not Acceptable",
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedooh "407 Proxy Authentication Required",
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedooh "408 Request Time-out",
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedooh "409 Conflict",
91654e263480f0fdc2a03d782ff23f8dad07cf79humbedooh "411 Length Required",
91814c869ca39ce45dfe147307d2a831cac6ecbehumbedooh "412 Precondition Failed",
91654e263480f0fdc2a03d782ff23f8dad07cf79humbedooh "413 Request Entity Too Large",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "414 Request-URI Too Large",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "415 Unsupported Media Type",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "416 Requested Range Not Satisfiable",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "417 Expectation Failed",
c967bf3bc89e8aa60dbd30d9da388e448ddc1cc4trawick "418 unused",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "419 unused",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "420 unused",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "421 unused",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "422 Unprocessable Entity",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "423 Locked",
12b987b969f03ef98d9175a53d849ab62f5684fecovener "424 Failed Dependency",
12b987b969f03ef98d9175a53d849ab62f5684fecovener /* This is a hack, but it is required for ap_index_of_response
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton * to work with 426.
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton "425 No code",
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton "426 Upgrade Required",
536e48c08d674acac5d44929318f2ad928edc361jorton "500 Internal Server Error",
e81785da447b469da66f218b3f0244aab507958djorton "501 Method Not Implemented",
e81785da447b469da66f218b3f0244aab507958djorton "502 Bad Gateway",
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton "503 Service Temporarily Unavailable",
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton "504 Gateway Time-out",
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton "505 HTTP Version Not Supported",
53e9b27aba029b18be814df40bcf6f0428771d1efuankg "506 Variant Also Negotiates",
53e9b27aba029b18be814df40bcf6f0428771d1efuankg "507 Insufficient Storage",
53e9b27aba029b18be814df40bcf6f0428771d1efuankg "508 unused",
53e9b27aba029b18be814df40bcf6f0428771d1efuankg "509 unused",
53e9b27aba029b18be814df40bcf6f0428771d1efuankg "510 Not Extended"
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrinAP_IMPLEMENT_HOOK_VOID(insert_error_filter, (request_rec *r), (r))
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin/* The index of the first bit field that is used to index into a limit
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin * bitmask. M_INVALID + 1 to METHOD_NUMBER_LAST.
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung/* The max method number. Method numbers are used to shift bitmasks,
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung * so this cannot exceed 63, and all bits high is equal to -1, which is a
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung * special flag, so the last bit used has index 62.
cfa64348224b66dd1c9979b809406c4d15b1c137fielding const char *conn = apr_table_get(r->headers_in, "Connection");
cfa64348224b66dd1c9979b809406c4d15b1c137fielding /* The following convoluted conditional determines whether or not
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim * the current connection should remain persistent after this response
cfa64348224b66dd1c9979b809406c4d15b1c137fielding * (a.k.a. HTTP Keep-Alive) and whether or not the output message
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim * body should use the HTTP/1.1 chunked transfer-coding. In English,
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim * IF we have not marked this connection as errored;
cfa64348224b66dd1c9979b809406c4d15b1c137fielding * and the response body has a defined length due to the status code
|| r->header_only
&& !wimpy
&& !ap_graceful_stop_signalled()) {
if (ka_sent) {
left));
if (!wimpy) {
const char *etag;
int not_modified = 0;
return OK;
return HTTP_PRECONDITION_FAILED;
return HTTP_PRECONDITION_FAILED;
return HTTP_PRECONDITION_FAILED;
&& (if_modified_since =
if (not_modified) {
return HTTP_NOT_MODIFIED;
return OK;
int methnum)
return APR_SUCCESS;
int *methnum;
return M_INVALID;
return *methnum;
return M_INVALID;
return cur_method_number++;
the "cocom" parsing/compilation toolkit. It is an optimized lookup
switch (len)
switch (method[0])
return UNKNOWN_METHOD;
switch (method[0])
return UNKNOWN_METHOD;
return UNKNOWN_METHOD;
switch (method[0])
return UNKNOWN_METHOD;
return UNKNOWN_METHOD;
return UNKNOWN_METHOD;
switch (method[0])
return UNKNOWN_METHOD;
switch (method[0])
return UNKNOWN_METHOD;
return UNKNOWN_METHOD;
* something like a mod_http_methods.c, complete with config stuff.
return which;
return *methnum;
return M_INVALID;
const void *key;
void *val;
return key;
return NULL;
int i, pos;
return LEVEL_500;
return pos;
char *list;
const void *key;
void *val;
return list;
if (r->assbackwards) {
return DECLINED;
return OK;
if (!ct) {
const char *prefix,
const char *key,
const char *suffix)
return result;
request_rec *r,
const char *location)
switch (status) {
case HTTP_MOVED_PERMANENTLY:
case HTTP_MOVED_TEMPORARILY:
case HTTP_TEMPORARY_REDIRECT:
return(apr_pstrcat(p,
NULL));
case HTTP_SEE_OTHER:
return(apr_pstrcat(p,
NULL));
case HTTP_USE_PROXY:
return(apr_pstrcat(p,
NULL));
case HTTP_UNAUTHORIZED:
case HTTP_BAD_REQUEST:
return(add_optional_notes(r,
case HTTP_FORBIDDEN:
return(apr_pstrcat(p,
NULL));
case HTTP_NOT_FOUND:
return(apr_pstrcat(p,
NULL));
case HTTP_METHOD_NOT_ALLOWED:
return(apr_pstrcat(p,
NULL));
case HTTP_NOT_ACCEPTABLE:
NULL);
case HTTP_MULTIPLE_CHOICES:
case HTTP_LENGTH_REQUIRED:
r->method,
NULL);
case HTTP_PRECONDITION_FAILED:
return(apr_pstrcat(p,
NULL));
case HTTP_NOT_IMPLEMENTED:
NULL);
case HTTP_BAD_GATEWAY:
case HTTP_VARIANT_ALSO_VARIES:
return(apr_pstrcat(p,
NULL));
case HTTP_REQUEST_TIME_OUT:
case HTTP_GONE:
return(apr_pstrcat(p,
NULL));
return(apr_pstrcat(p,
r->method,
NULL));
case HTTP_EXPECTATION_FAILED:
return(apr_pstrcat(p,
NULL));
case HTTP_LOCKED:
case HTTP_FAILED_DEPENDENCY:
case HTTP_UPGRADE_REQUIRED:
"using https://\n");
case HTTP_SERVICE_UNAVAILABLE:
case HTTP_GATEWAY_TIME_OUT:
case HTTP_NOT_EXTENDED:
return(apr_pstrcat(p,
NULL));
char *custom_response;
r->eos_sent = 0;
if (!r->assbackwards) {
r->clength = 0;
if (r->header_only) {
const char *h1;
NULL);
NULL);
if (recursive_error) {
return ml;
char **imethods;
char **omethods;
int methnum;
char **methods;
int methnum;
const char **xmethod;
char **methods;
const char *method)
int methnum;
char **methods;
l->method_mask = 0;