http_core.c revision b0d8a6d437db6f4c222173f27ef81c98622fbd02
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "apr_strings.h"
#include "apr_thread_proc.h" /* for RLIMIT stuff */
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "httpd.h"
#include "http_config.h"
#include "http_connection.h"
#include "http_core.h"
#include "http_protocol.h" /* For index_of_response(). Grump. */
#include "http_request.h"
#include "util_filter.h"
#include "util_ebcdic.h"
#include "ap_mpm.h"
#include "scoreboard.h"
#include "mod_core.h"
/* Handles for core filters */
static int ap_process_http_connection(conn_rec *c);
const char *arg)
{
return err;
}
return NULL;
}
const char *arg)
{
return err;
}
* so we accept anything but "Off" or "0" as "On"
*/
}
else {
}
return NULL;
}
const char *arg)
{
return err;
}
return NULL;
}
static const command_rec http_cmds[] = {
"Keep-Alive timeout duration (sec)"),
"Maximum number of Keep-Alive requests per connection, "
"or 0 for infinite"),
"Whether persistent connections should be On or Off"),
{ NULL }
};
static const char *http_scheme(const request_rec *r)
{
/*
* The http module shouldn't return anything other than
* "http" (the default) or "https".
*/
if (r->server->server_scheme &&
return "https";
return "http";
}
{
if (r->server->server_scheme &&
return DEFAULT_HTTPS_PORT;
return DEFAULT_HTTP_PORT;
}
static int ap_process_http_async_connection(conn_rec *c)
{
request_rec *r;
if (c->clogging_input_filters) {
return ap_process_http_connection(c);
}
if ((r = ap_read_request(c))) {
c->keepalive = AP_CONN_UNKNOWN;
/* process the request if it was read without error */
/* After the call to ap_process_request, the
* request pool may have been deleted. We set
* r=NULL here to ensure that any dereference
* of r that might be added later in this function
* will result in a segfault immediately instead
* of nondeterministic failures later.
*/
r = NULL;
}
/* Something went wrong; close the connection */
}
}
else { /* ap_read_request failed - client may have closed */
}
}
return OK;
}
static int ap_process_http_connection(conn_rec *c)
{
request_rec *r;
int mpm_state = 0;
/*
* Read and process each request found on our connection
* until no requests are left or we decide to close.
*/
while ((r = ap_read_request(c)) != NULL) {
c->keepalive = AP_CONN_UNKNOWN;
/* process the request if it was read without error */
/* After the call to ap_process_request, the
* request pool will have been deleted. We set
* r=NULL here to ensure that any dereference
* of r that might be added later in this function
* will result in a segfault immediately instead
* of nondeterministic failures later.
*/
r = NULL;
}
break;
break;
}
if (mpm_state == AP_MPMQ_STOPPING) {
break;
}
if (!csd) {
}
/* Go straight to select() to wait for the next request */
}
return OK;
}
static int http_create_request(request_rec *r)
{
NULL, r, r->connection);
NULL, r, r->connection);
NULL, r, r->connection);
NULL, r, r->connection);
}
return OK;
}
static int http_send_options(request_rec *r)
{
return DONE; /* Send HTTP pong, without Allow header */
}
return DECLINED;
}
static void register_hooks(apr_pool_t *p)
{
/**
* If we ae using an MPM That Supports Async Connections,
* use a different processing function
*/
int async_mpm = 0;
&& async_mpm == 1) {
}
else {
}
}
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
http_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};