Blame include/http_connection.h

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @file  http_connection.h
Packit 90a5c9
 * @brief Apache connection library
Packit 90a5c9
 *
Packit 90a5c9
 * @defgroup APACHE_CORE_CONNECTION Connection Library
Packit 90a5c9
 * @ingroup  APACHE_CORE
Packit 90a5c9
 * @{
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef APACHE_HTTP_CONNECTION_H
Packit 90a5c9
#define APACHE_HTTP_CONNECTION_H
Packit 90a5c9
Packit 90a5c9
#include "apr_network_io.h"
Packit 90a5c9
#include "apr_buckets.h"
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
extern "C" {
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This is the protocol module driver.  This calls all of the
Packit 90a5c9
 * pre-connection and connection hooks for all protocol modules.
Packit 90a5c9
 * @param c The connection on which the request is read
Packit 90a5c9
 * @param csd The mechanism on which this connection is to be read.
Packit 90a5c9
 *            Most times this will be a socket, but it is up to the module
Packit 90a5c9
 *            that accepts the request to determine the exact type.
Packit 90a5c9
 */
Packit 90a5c9
AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Shutdown the connection for writing.
Packit 90a5c9
 * @param c The connection to shutdown
Packit 90a5c9
 * @param flush Whether or not to flush pending data before
Packit 90a5c9
 * @return APR_SUCCESS or the underlying error
Packit 90a5c9
 */
Packit 90a5c9
AP_CORE_DECLARE(apr_status_t) ap_shutdown_conn(conn_rec *c, int flush);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Flushes all remain data in the client send buffer
Packit 90a5c9
 * @param c The connection to flush
Packit 90a5c9
 * @remark calls ap_shutdown_conn(c, 1)
Packit 90a5c9
 */
Packit 90a5c9
AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This function is responsible for the following cases:
Packit 90a5c9
 * 
Packit 90a5c9
 * we now proceed to read from the client until we get EOF, or until
Packit 90a5c9
 * MAX_SECS_TO_LINGER has passed.  The reasons for doing this are
Packit 90a5c9
 * documented in a draft:
Packit 90a5c9
 *
Packit 90a5c9
 * http://tools.ietf.org/html/draft-ietf-http-connection-00.txt
Packit 90a5c9
 *
Packit 90a5c9
 * in a nutshell -- if we don't make this effort we risk causing
Packit 90a5c9
 * TCP RST packets to be sent which can tear down a connection before
Packit 90a5c9
 * all the response data has been sent to the client.
Packit 90a5c9
 * 
Packit 90a5c9
 * @param c The connection we are closing
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_lingering_close(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
AP_DECLARE(int) ap_prep_lingering_close(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
AP_DECLARE(int) ap_start_lingering_close(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
/* Hooks */
Packit 90a5c9
/**
Packit 90a5c9
 * create_connection is a RUN_FIRST hook which allows modules to create
Packit 90a5c9
 * connections. In general, you should not install filters with the
Packit 90a5c9
 * create_connection hook. If you require vhost configuration information
Packit 90a5c9
 * to make filter installation decisions, you must use the pre_connection
Packit 90a5c9
 * or install_network_transport hook. This hook should close the connection
Packit 90a5c9
 * if it encounters a fatal error condition.
Packit 90a5c9
 *
Packit 90a5c9
 * @param p The pool from which to allocate the connection record
Packit 90a5c9
 * @param server The server record to create the connection too.
Packit 90a5c9
 * @param csd The socket that has been accepted
Packit 90a5c9
 * @param conn_id A unique identifier for this connection.  The ID only
Packit 90a5c9
 *                needs to be unique at that time, not forever.
Packit 90a5c9
 * @param sbh A handle to scoreboard information for this connection.
Packit 90a5c9
 * @param alloc The bucket allocator to use for all bucket/brigade creations
Packit 90a5c9
 * @return An allocated connection record or NULL.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(conn_rec *, create_connection,
Packit 90a5c9
                (apr_pool_t *p, server_rec *server, apr_socket_t *csd,
Packit 90a5c9
                 long conn_id, void *sbh, apr_bucket_alloc_t *alloc))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook gives protocol modules an opportunity to set everything up
Packit 90a5c9
 * before calling the protocol handler.  All pre-connection hooks are
Packit 90a5c9
 * run until one returns something other than ok or decline
Packit 90a5c9
 * @param c The connection on which the request has been received.
Packit 90a5c9
 * @param csd The mechanism on which this connection is to be read.
Packit 90a5c9
 *            Most times this will be a socket, but it is up to the module
Packit 90a5c9
 *            that accepts the request to determine the exact type.
Packit 90a5c9
 * @return OK or DECLINED
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,pre_connection,(conn_rec *c, void *csd))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook implements different protocols.  After a connection has been
Packit 90a5c9
 * established, the protocol module must read and serve the request.  This
Packit 90a5c9
 * function does that for each protocol module.  The first protocol module
Packit 90a5c9
 * to handle the request is the last module run.
Packit 90a5c9
 * @param c The connection on which the request has been received.
Packit 90a5c9
 * @return OK or DECLINED
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,process_connection,(conn_rec *c))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook implements different protocols.  Before a connection is closed,
Packit 90a5c9
 * protocols might have to perform some housekeeping actions, such as 
Packit 90a5c9
 * sending one last goodbye packet. The connection is, unless some other
Packit 90a5c9
 * error already happened before, still open and operational.
Packit 90a5c9
 * All pre-close-connection hooks are run until one returns something 
Packit 90a5c9
 * other than ok or decline
Packit 90a5c9
 * @param c The connection on which the request has been received.
Packit 90a5c9
 * @return OK or DECLINED
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,pre_close_connection,(conn_rec *c))
Packit 90a5c9
Packit 90a5c9
/** End Of Connection (EOC) bucket */
Packit 90a5c9
AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Determine if a bucket is an End Of Connection (EOC) bucket
Packit 90a5c9
 * @param e The bucket to inspect
Packit 90a5c9
 * @return true or false
Packit 90a5c9
 */
Packit 90a5c9
#define AP_BUCKET_IS_EOC(e)         (e->type == &ap_bucket_type_eoc)
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Make the bucket passed in an End Of Connection (EOC) bucket
Packit 90a5c9
 * @param b The bucket to make into an EOC bucket
Packit 90a5c9
 * @return The new bucket, or NULL if allocation failed
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_bucket *) ap_bucket_eoc_make(apr_bucket *b);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Create a bucket referring to an End Of Connection (EOC). This indicates
Packit 90a5c9
 * that the connection will be closed.
Packit 90a5c9
 * @param list The freelist from which this bucket should be allocated
Packit 90a5c9
 * @return The new bucket, or NULL if allocation failed
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_bucket *) ap_bucket_eoc_create(apr_bucket_alloc_t *list);
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
}
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#endif  /* !APACHE_HTTP_CONNECTION_H */
Packit 90a5c9
/** @} */