]> granicus.if.org Git - apache/blob - include/http_protocol.h
Remove all of the calls to functions like "ap_popenf". These functions were
[apache] / include / http_protocol.h
1 /* ====================================================================
2  * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in
13  *    the documentation and/or other materials provided with the
14  *    distribution.
15  *
16  * 3. All advertising materials mentioning features or use of this
17  *    software must display the following acknowledgment:
18  *    "This product includes software developed by the Apache Group
19  *    for use in the Apache HTTP server project (http://www.apache.org/)."
20  *
21  * 4. The names "Apache Server" and "Apache Group" must not be used to
22  *    endorse or promote products derived from this software without
23  *    prior written permission. For written permission, please contact
24  *    apache@apache.org.
25  *
26  * 5. Products derived from this software may not be called "Apache"
27  *    nor may "Apache" appear in their names without prior written
28  *    permission of the Apache Group.
29  *
30  * 6. Redistributions of any form whatsoever must retain the following
31  *    acknowledgment:
32  *    "This product includes software developed by the Apache Group
33  *    for use in the Apache HTTP server project (http://www.apache.org/)."
34  *
35  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
36  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46  * OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Apache Group and was originally based
51  * on public domain software written at the National Center for
52  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
53  * For more information on the Apache Group and the Apache HTTP server
54  * project, please see <http://www.apache.org/>.
55  *
56  */
57
58 #ifndef APACHE_HTTP_PROTOCOL_H
59 #define APACHE_HTTP_PROTOCOL_H
60
61 #include "ap_hooks.h"
62 #include "apr_portable.h"
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
68 /*
69  * Prototypes for routines which either talk directly back to the user,
70  * or control the ones that eventually do.
71  */
72
73 /* Read a request and fill in the fields. */
74
75 request_rec *ap_read_request(conn_rec *c);
76
77 /* Send a single HTTP header field */
78
79 API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, const char *fieldname,
80                       const char *fieldval);
81
82 /* Send the minimal part of an HTTP response header... but modules should be
83  * very careful about using this, and should prefer ap_send_http_header().
84  * Much of the HTTP/1.1 implementation correctness depends on code in
85  * ap_send_http_header().
86  */
87 API_EXPORT(void) ap_basic_http_header(request_rec *r);
88
89 /* Send the Status-Line and header fields for HTTP response */
90
91 API_EXPORT(void) ap_send_http_header(request_rec *l);
92
93 /* Send the response to special method requests */
94
95 API_EXPORT(int) ap_send_http_trace(request_rec *r);
96 int ap_send_http_options(request_rec *r);
97
98 /* Finish up stuff after a request */
99
100 API_EXPORT(void) ap_finalize_request_protocol(request_rec *r);
101
102 /* Send error back to client... last arg indicates error status in case
103  * we get an error in the process of trying to deal with an ErrorDocument
104  * to handle some other error.  In that case, we print the default report
105  * for the first thing that went wrong, and more briefly report on the
106  * problem with the ErrorDocument.
107  */
108
109 void ap_send_error_response(request_rec *r, int recursive_error);
110
111 /* Set last modified header line from the lastmod date of the associated file.
112  * Also, set content length.
113  *
114  * May return an error status, typically USE_LOCAL_COPY (that when the
115  * permit_cache argument is set to one).
116  */
117
118 API_EXPORT(int) ap_set_content_length(request_rec *r, long length);
119 API_EXPORT(int) ap_set_keepalive(request_rec *r);
120 API_EXPORT(time_t) ap_rationalize_mtime(request_rec *r, time_t mtime);
121 API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak);
122 API_EXPORT(void) ap_set_etag(request_rec *r);
123 API_EXPORT(void) ap_set_last_modified(request_rec *r);
124 API_EXPORT(int) ap_meets_conditions(request_rec *r);
125
126 /* Other ways to send stuff at the client.  All of these keep track
127  * of bytes_sent automatically.  This indirection is intended to make
128  * it a little more painless to slide things like HTTP-NG packetization
129  * underneath the main body of the code later.  In the meantime, it lets
130  * us centralize a bit of accounting (bytes_sent).
131  *
132  * These also return the number of bytes written by the call.
133  * They should only be called with a timeout registered, for obvious reaasons.
134  * (Ditto the send_header stuff).
135  */
136
137 API_EXPORT(long) ap_send_fd(int fd, request_rec *r);
138 API_EXPORT(long) ap_send_fd_length(int fd, request_rec *r, long length);
139
140 API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r);
141 API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length);
142
143 API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset,
144                              size_t length);
145
146 /* Hmmm... could macrofy these for now, and maybe forever, though the
147  * definitions of the macros would get a whole lot hairier.
148  */
149
150 API_EXPORT(int) ap_rputc(int c, request_rec *r);
151 API_EXPORT(int) ap_rputs(const char *str, request_rec *r);
152 API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
153 API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...);
154 API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
155 API_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
156                                 __attribute__((format(printf,2,3)));
157 API_EXPORT(int) ap_rflush(request_rec *r);
158
159 /*
160  * Index used in custom_responses array for a specific error code
161  * (only use outside protocol.c is in getting them configured).
162  */
163
164 API_EXPORT(int) ap_index_of_response(int status);
165
166 /* Reading a block of data from the client connection (e.g., POST arg) */
167
168 API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy);
169 API_EXPORT(int) ap_should_client_block(request_rec *r);
170 API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz);
171 API_EXPORT(int) ap_discard_request_body(request_rec *r);
172
173 /* Sending a byterange */
174
175 API_EXPORT(int) ap_set_byterange(request_rec *r);
176 API_EXPORT(int) ap_each_byterange(request_rec *r, long *offset, long *length);
177
178 /* Support for the Basic authentication protocol.  Note that there's
179  * nothing that prevents these from being in mod_auth.c, except that other
180  * modules which wanted to provide their own variants on finding users and
181  * passwords for Basic auth (a fairly common request) would then require
182  * mod_auth to be loaded or they wouldn't work.
183  *
184  * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured
185  * a correct value in r->connection->user); otherwise it returns an error
186  * code, either SERVER_ERROR if things are really confused, AUTH_REQUIRED
187  * if no authentication at all seemed to be in use, or DECLINED if there
188  * was authentication but it wasn't Basic (in which case, the caller should
189  * presumably decline as well).
190  *
191  * note_basic_auth_failure arranges for the right stuff to be scribbled on
192  * the HTTP return so that the client knows how to authenticate itself the
193  * next time. As does note_digest_auth_failure for Digest auth.
194  *
195  * note_auth_failure does the same thing, but will call the correct one
196  * based on the authentication type in use.
197  *
198  */
199
200 API_EXPORT(void) ap_note_auth_failure(request_rec *r);
201 API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r);
202 API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r);
203 API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
204
205 /*
206  * Setting up the protocol fields for subsidiary requests...
207  * Also, a wrapup function to keep the internal accounting straight.
208  */
209
210 void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
211 void ap_finalize_sub_req_protocol(request_rec *sub_r);
212
213 /* This is also useful for putting sub_reqs and internal_redirects together */
214
215 CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri);
216
217 /* Get the method number associated with the given string, assumed to
218  * contain an HTTP method.  Returns M_INVALID if not recognized.
219  */
220 API_EXPORT(int) ap_method_number_of(const char *method);
221
222   /* Hooks */
223   /*
224    * post_read_request --- run right after read_request or internal_redirect,
225    *                  and not run during any subrequests.
226    */
227 DECLARE_HOOK(int,post_read_request,(request_rec *))
228 DECLARE_HOOK(int,log_transaction,(request_rec *))
229 DECLARE_HOOK(const char *,http_method,(const request_rec *))
230 DECLARE_HOOK(unsigned short,default_port,(const request_rec *))
231
232 #ifdef __cplusplus
233 }
234 #endif
235
236 #endif  /* !APACHE_HTTP_PROTOCOL_H */