1 | /* Licensed to the Apache Software Foundation (ASF) under one or more |
2 | * contributor license agreements. See the NOTICE file distributed with |
3 | * this work for additional information regarding copyright ownership. |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
5 | * (the "License"); you may not use this file except in compliance with |
6 | * the License. You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | /** |
18 | * @file http_connection.h |
19 | * @brief Apache connection library |
20 | * |
21 | * @defgroup APACHE_CORE_CONNECTION Connection Library |
22 | * @ingroup APACHE_CORE |
23 | * @{ |
24 | */ |
25 | |
26 | #ifndef APACHE_HTTP_CONNECTION_H |
27 | #define APACHE_HTTP_CONNECTION_H |
28 | |
29 | #include "apr_hooks.h" |
30 | #include "apr_network_io.h" |
31 | #include "apr_buckets.h" |
32 | |
33 | #ifdef __cplusplus |
34 | extern "C" { |
35 | #endif |
36 | /** |
37 | * @file http_connection.h |
38 | * @brief Apache connection library |
39 | */ |
40 | |
41 | #ifdef CORE_PRIVATE |
42 | /** |
43 | * This is the protocol module driver. This calls all of the |
44 | * pre-connection and connection hooks for all protocol modules. |
45 | * @param c The connection on which the request is read |
46 | * @param csd The mechanism on which this connection is to be read. |
47 | * Most times this will be a socket, but it is up to the module |
48 | * that accepts the request to determine the exact type. |
49 | */ |
50 | AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd); |
51 | |
52 | /** |
53 | * Flushes all remain data in the client send buffer |
54 | * @param c The connection to flush |
55 | */ |
56 | AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c); |
57 | |
58 | /** |
59 | * This function is responsible for the following cases: |
60 | * <pre> |
61 | * we now proceed to read from the client until we get EOF, or until |
62 | * MAX_SECS_TO_LINGER has passed. the reasons for doing this are |
63 | * documented in a draft: |
64 | * |
65 | * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt |
66 | * |
67 | * in a nutshell -- if we don't make this effort we risk causing |
68 | * TCP RST packets to be sent which can tear down a connection before |
69 | * all the response data has been sent to the client. |
70 | * </pre> |
71 | * @param c The connection we are closing |
72 | */ |
73 | AP_DECLARE(void) ap_lingering_close(conn_rec *c); |
74 | #endif |
75 | |
76 | /* Hooks */ |
77 | /** |
78 | * create_connection is a RUN_FIRST hook which allows modules to create |
79 | * connections. In general, you should not install filters with the |
80 | * create_connection hook. If you require vhost configuration information |
81 | * to make filter installation decisions, you must use the pre_connection |
82 | * or install_network_transport hook. This hook should close the connection |
83 | * if it encounters a fatal error condition. |
84 | * |
85 | * @param p The pool from which to allocate the connection record |
86 | * @param server The server record to create the connection too. |
87 | * @param csd The socket that has been accepted |
88 | * @param conn_id A unique identifier for this connection. The ID only |
89 | * needs to be unique at that time, not forever. |
90 | * @param sbh A handle to scoreboard information for this connection. |
91 | * @param alloc The bucket allocator to use for all bucket/brigade creations |
92 | * @return An allocated connection record or NULL. |
93 | */ |
94 | AP_DECLARE_HOOK(conn_rec *, create_connection, |
95 | (apr_pool_t *p, server_rec *server, apr_socket_t *csd, |
96 | long conn_id, void *sbh, apr_bucket_alloc_t *alloc)) |
97 | |
98 | /** |
99 | * This hook gives protocol modules an opportunity to set everything up |
100 | * before calling the protocol handler. All pre-connection hooks are |
101 | * run until one returns something other than ok or decline |
102 | * @param c The connection on which the request has been received. |
103 | * @param csd The mechanism on which this connection is to be read. |
104 | * Most times this will be a socket, but it is up to the module |
105 | * that accepts the request to determine the exact type. |
106 | * @return OK or DECLINED |
107 | */ |
108 | AP_DECLARE_HOOK(int,pre_connection,(conn_rec *c, void *csd)) |
109 | |
110 | /** |
111 | * This hook implements different protocols. After a connection has been |
112 | * established, the protocol module must read and serve the request. This |
113 | * function does that for each protocol module. The first protocol module |
114 | * to handle the request is the last module run. |
115 | * @param c The connection on which the request has been received. |
116 | * @return OK or DECLINED |
117 | */ |
118 | AP_DECLARE_HOOK(int,process_connection,(conn_rec *c)) |
119 | |
120 | /** End Of Connection (EOC) bucket */ |
121 | AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc; |
122 | |
123 | /** |
124 | * Determine if a bucket is an End Of Connection (EOC) bucket |
125 | * @param e The bucket to inspect |
126 | * @return true or false |
127 | */ |
128 | #define AP_BUCKET_IS_EOC(e) (e-> : enter=0, leave=0 ->type : /usr/include/apr-1/apr_buckets.h line=228 column=30
type == : true=0, false=0 MC/DC independently affect : true=0, false=0 == &ap_bucket_type_eoc : include/http_connection.h line=121 column=48
ap_bucket_type_eoc) |
129 | |
130 | /** |
131 | * Make the bucket passed in an End Of Connection (EOC) bucket |
132 | * @param b The bucket to make into an EOC bucket |
133 | * @return The new bucket, or NULL if allocation failed |
134 | */ |
135 | AP_DECLARE(apr_bucket *) ap_bucket_eoc_make(apr_bucket *b); |
136 | |
137 | /** |
138 | * Create a bucket referring to an End Of Connection (EOC). This indicates |
139 | * that the connection will be closed. |
140 | * @param list The freelist from which this bucket should be allocated |
141 | * @return The new bucket, or NULL if allocation failed |
142 | */ |
143 | AP_DECLARE(apr_bucket *) ap_bucket_eoc_create(apr_bucket_alloc_t *list); |
144 | |
145 | #ifdef __cplusplus |
146 | } |
147 | #endif |
148 | |
149 | #endif /* !APACHE_HTTP_REQUEST_H */ |
150 | /** @} */ |
151 | [EOF] |