Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

http_connection.h

Go to the documentation of this file.
00001 /* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APACHE_HTTP_CONNECTION_H
00018 #define APACHE_HTTP_CONNECTION_H
00019 
00020 #include "apr_hooks.h"
00021 #include "apr_network_io.h"
00022 #include "apr_buckets.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /**
00029  * @package Apache connection library
00030  */
00031 #ifdef CORE_PRIVATE
00032 /**
00033  * This is the protocol module driver.  This calls all of the
00034  * pre-connection and connection hooks for all protocol modules.
00035  * @param c The connection on which the request is read
00036  * @param csd The mechanism on which this connection is to be read.  
00037  *            Most times this will be a socket, but it is up to the module
00038  *            that accepts the request to determine the exact type.
00039  * @deffunc void ap_process_connection(conn_rec *c, void *csd)
00040  */
00041 AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd);
00042 
00043 AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c);
00044 
00045 /**
00046  * This function is responsible for the following cases:
00047  * <pre>
00048  * we now proceed to read from the client until we get EOF, or until
00049  * MAX_SECS_TO_LINGER has passed.  the reasons for doing this are
00050  * documented in a draft:
00051  *
00052  * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt
00053  *
00054  * in a nutshell -- if we don't make this effort we risk causing
00055  * TCP RST packets to be sent which can tear down a connection before
00056  * all the response data has been sent to the client.
00057  * </pre>
00058  * @param c The connection we are closing
00059  */
00060 AP_DECLARE(void) ap_lingering_close(conn_rec *c);
00061 #endif
00062 
00063   /* Hooks */
00064 /**
00065  * create_connection is a RUN_FIRST hook which allows modules to create 
00066  * connections. In general, you should not install filters with the 
00067  * create_connection hook. If you require vhost configuration information 
00068  * to make filter installation decisions, you must use the pre_connection
00069  * or install_network_transport hook. This hook should close the connection
00070  * if it encounters a fatal error condition.
00071  *
00072  * @param p The pool from which to allocate the connection record
00073  * @param csd The socket that has been accepted
00074  * @param conn_id A unique identifier for this connection.  The ID only
00075  *                needs to be unique at that time, not forever.
00076  * @param sbh A handle to scoreboard information for this connection.
00077  * @return An allocated connection record or NULL.
00078  */
00079 AP_DECLARE_HOOK(conn_rec *, create_connection,
00080                 (apr_pool_t *p, server_rec *server, apr_socket_t *csd,
00081                  long conn_id, void *sbh, apr_bucket_alloc_t *alloc))
00082    
00083 /**
00084  * This hook gives protocol modules an opportunity to set everything up
00085  * before calling the protocol handler.  All pre-connection hooks are
00086  * run until one returns something other than ok or decline
00087  * @param c The connection on which the request has been received.
00088  * @param csd The mechanism on which this connection is to be read.  
00089  *            Most times this will be a socket, but it is up to the module
00090  *            that accepts the request to determine the exact type.
00091  * @return OK or DECLINED
00092  * @deffunc int ap_run_pre_connection(conn_rec *c, void *csd)
00093  */
00094 AP_DECLARE_HOOK(int,pre_connection,(conn_rec *c, void *csd))
00095 
00096 /**
00097  * This hook implements different protocols.  After a connection has been
00098  * established, the protocol module must read and serve the request.  This
00099  * function does that for each protocol module.  The first protocol module
00100  * to handle the request is the last module run.
00101  * @param c The connection on which the request has been received.
00102  * @return OK or DECLINED
00103  * @deffunc int ap_run_process_connection(conn_rec *c)
00104  */
00105 AP_DECLARE_HOOK(int,process_connection,(conn_rec *c))
00106 
00107 /* End Of Connection (EOC) bucket */
00108 
00109 AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc;
00110 
00111 /**
00112  * Determine if a bucket is an End Of Connection (EOC) bucket
00113  * @param e The bucket to inspect
00114  * @return true or false
00115  */
00116 #define AP_BUCKET_IS_EOC(e)         (e->type == &ap_bucket_type_eoc)
00117 
00118 /**
00119  * Make the bucket passed in an End Of Connection (EOC) bucket
00120  * @param b The bucket to make into an EOC bucket
00121  * @return The new bucket, or NULL if allocation failed
00122  * @deffunc apr_bucket *ap_bucket_eoc_make(apr_bucket *b)
00123  */
00124 AP_DECLARE(apr_bucket *) ap_bucket_eoc_make(apr_bucket *b);
00125 
00126 /**
00127  * Create a bucket referring to an End Of Connection (EOC). This indicates
00128  * that the connection will be closed.
00129  * @param list The freelist from which this bucket should be allocated
00130  * @return The new bucket, or NULL if allocation failed
00131  * @deffunc apr_bucket *ap_bucket_eoc_create(apr_bucket_alloc_t *list)
00132  */
00133 AP_DECLARE(apr_bucket *) ap_bucket_eoc_create(apr_bucket_alloc_t *list);
00134 
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138 
00139 #endif  /* !APACHE_HTTP_REQUEST_H */