Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
http_protocol.h
Go to the documentation of this file.
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 
26 #ifndef APACHE_HTTP_PROTOCOL_H
27 #define APACHE_HTTP_PROTOCOL_H
28 
29 #include "httpd.h"
30 #include "apr_portable.h"
31 #include "apr_mmap.h"
32 #include "apr_buckets.h"
33 #include "util_filter.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
45 
46 
50 
51 /*
52  * Prototypes for routines which either talk directly back to the user,
53  * or control the ones that eventually do.
54  */
55 
62 
69 
75 
84 
85 /* Finish up stuff after a request */
86 
93 
103 AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
104 
105 /* Set last modified header line from the lastmod date of the associated file.
106  * Also, set content length.
107  *
108  * May return an error status, typically HTTP_NOT_MODIFIED (that when the
109  * permit_cache argument is set to one).
110  */
111 
118 
125 
134 
147  const char *type);
148 
154 
163 AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
164 
170 
176 
177 typedef enum {
183 
193  apr_table_t *headers);
194 
205  apr_table_t *headers);
206 
217  apr_table_t *headers);
218 
229  apr_table_t *headers);
230 
241  apr_table_t *headers);
242 
252 
253 /* Other ways to send stuff at the client. All of these keep track
254  * of bytes_sent automatically. This indirection is intended to make
255  * it a little more painless to slide things like HTTP-NG packetization
256  * underneath the main body of the code later. In the meantime, it lets
257  * us centralize a bit of accounting (bytes_sent).
258  *
259  * These also return the number of bytes written by the call.
260  * They should only be called with a timeout registered, for obvious reaasons.
261  * (Ditto the send_header stuff).
262  */
263 
274  apr_size_t length, apr_size_t *nbytes);
275 
276 #if APR_HAS_MMAP
277 
286  request_rec *r,
287  apr_size_t offset,
288  apr_size_t length);
289 #endif
290 
291 
300 AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
301 
308 
313 #define AP_METHOD_CHECK_ALLOWED(mask, methname) \
314  ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
315 
326 
327 
336 
345 AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
346 
355 AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
356 
365  const char *method);
366 
374 
382 AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
383 
389 
390 
391 /* Hmmm... could macrofy these for now, and maybe forever, though the
392  * definitions of the macros would get a whole lot hairier.
393  */
394 
401 AP_DECLARE(int) ap_rputc(int c, request_rec *r);
402 
410 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
411 
419 static APR_INLINE int ap_rputs(const char *str, request_rec *r)
420 {
421  return ap_rwrite(str, (int)strlen(str), r);
422 }
423 
432 
440 AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
441 
449 AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
450  __attribute__((format(printf,2,3)));
451 
458 
466 
474 AP_DECLARE(const char *) ap_get_status_line(int status);
475 
485 AP_DECLARE(const char *) ap_get_status_line_ex(apr_pool_t *p, int status);
486 
487 /* Reading a block of data from the client connection (e.g., POST arg) */
488 
500 AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
501 
511 
521 AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
522 
539 
551 
558 
563 
568 
576 AP_DECLARE_HOOK(int, note_auth_failure, (request_rec *r, const char *auth_type))
577 
601 AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
602 
603 #define AP_GET_BASIC_AUTH_PW_NOTE "AP_GET_BASIC_AUTH_PW_NOTE"
604 
619  const char **username,
620  const char **password);
621 
631 AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
632 
633 #define AP_GETLINE_FOLD (1 << 0) /* Whether to merge continuation lines */
634 #define AP_GETLINE_CRLF (1 << 1) /* Whether line ends must be CRLF */
635 #define AP_GETLINE_NOSPC_EOL (1 << 2) /* Whether to consume up to and including
636  the end of line on APR_ENOSPC */
637 #define AP_GETLINE_NONBLOCK (1 << 3) /* Whether to read non-blocking */
638 
649 AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int flags);
650 
668  apr_size_t *read, ap_filter_t *f,
669  int flags, apr_bucket_brigade *bb,
670  apr_pool_t *p);
671 
679  apr_size_t *read, request_rec *r,
680  int flags, apr_bucket_brigade *bb);
681 
688 AP_DECLARE(int) ap_method_number_of(const char *method);
689 
697 AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
698 
699 
700 /* Hooks */
701 /*
702  * pre_read_request --- run right before read_request_line(),
703  * and not run during any subrequests.
704  */
713 
714 /*
715  * post_read_request --- run right after read_request or internal_redirect,
716  * and not run during any subrequests.
717  */
726 
734 
741 AP_DECLARE_HOOK(const char *,http_scheme,(const request_rec *r))
742 
749 
750 
751 #define AP_PROTOCOL_HTTP1 "http/1.1"
752 
788  server_rec *s,
789  const apr_array_header_t *offers,
790  apr_array_header_t *proposals))
791 
792 
816  server_rec *s,
817  const char *protocol))
818 
819 
830 AP_DECLARE_HOOK(const char *,protocol_get,(const conn_rec *c))
831 
832 
849  server_rec *s, int report_all,
850  const apr_array_header_t **pupgrades);
851 
867 AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r,
868  server_rec *s,
869  const apr_array_header_t *choices);
870 
886  server_rec *s,
887  const char *protocol);
888 
900 AP_DECLARE(const char *) ap_get_protocol(conn_rec *c);
901 
917  server_rec *s, const char *protocol);
918 
921 
931 struct ap_bucket_error {
935  int status;
937  const char *data;
938 };
939 
942 
948 #define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error)
949 
959  const char *buf, apr_pool_t *p);
960 
969 AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
970  apr_pool_t *p,
971  apr_bucket_alloc_t *list);
972 
977 AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b);
978 
985 
992 
998 AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers);
999 
1000 #ifdef __cplusplus
1001 }
1002 #endif
1003 
1004 #endif /* !APACHE_HTTP_PROTOCOL_H */
1005 
This structure is used for recording information about the registered filters. It associates a name w...
Definition: util_filter.h:226
apr_status_t ap_fgetline(char **s, apr_size_t n, apr_size_t *read, ap_filter_t *f, int flags, apr_bucket_brigade *bb, apr_pool_t *p)
size_t apr_size_t
Definition: apr.h:375
A bucket referring to an HTTP error.
Definition: http_protocol.h:931
int ap_discard_request_body(request_rec *r)
Definition: http_protocol.h:180
#define AP_CORE_DECLARE(x)
Definition: macros.h:3
int protocol_propose(conn_rec *c, request_rec *r, server_rec *s, const apr_array_header_t *offers, apr_array_header_t *proposals)
int ap_should_client_block(request_rec *r)
Definition: apr_arch_file_io.h:107
Definition: apr_tables.h:62
int ap_index_of_response(int status)
apr_status_t ap_switch_protocol(conn_rec *c, request_rec *r, server_rec *s, const char *protocol)
void ap_finalize_sub_req_protocol(request_rec *sub_r)
long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz)
ap_method_list_t * ap_make_method_list(apr_pool_t *p, int nelts)
int ap_is_allowed_protocol(conn_rec *c, request_rec *r, server_rec *s, const char *protocol)
apr_status_t __attribute__((nonnull(1)))
The representation of a filter chain.
Definition: util_filter.h:273
void ap_set_etag(request_rec *r)
#define AP_FN_ATTR_SENTINEL
Definition: ap_config.h:231
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:123
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
const char * ap_method_name_of(apr_pool_t *p, int methnum)
int ap_getline(char *s, int n, request_rec *r, int flags)
int ap_set_keepalive(request_rec *r)
#define AP_DECLARE(x)
Definition: macros.h:1
int status
Definition: http_protocol.h:935
void ap_note_auth_failure(request_rec *r)
request_rec * ap_create_request(conn_rec *c)
void ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb)
const char * ap_get_status_line_ex(apr_pool_t *p, int status)
void ap_set_content_length(request_rec *r, apr_off_t length)
void ap_copy_method_list(ap_method_list_t *dest, ap_method_list_t *src)
void insert_error_filter(request_rec *r)
#define AP_DECLARE_NONSTD(x)
Definition: macros.h:2
void ap_set_content_type(request_rec *r, const char *ct)
const char * ap_get_protocol(conn_rec *c)
apr_status_t ap_get_protocol_upgrades(conn_rec *c, request_rec *r, server_rec *s, int report_all, const apr_array_header_t **pupgrades)
Definition: http_protocol.h:179
void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r)
void ap_method_list_remove(ap_method_list_t *l, const char *method)
ap_condition_e ap_condition_if_modified_since(request_rec *r, apr_table_t *headers)
const char const char * uri
Definition: mod_dav.h:614
apr_status_t ap_content_length_filter(ap_filter_t *, apr_bucket_brigade *)
int log_transaction(request_rec *r)
Definition: apr_buckets.h:258
int ap_method_number_of(const char *method)
int protocol_switch(conn_rec *c, request_rec *r, server_rec *s, const char *protocol)
int post_read_request(request_rec *r)
Structure to store things which are per connection.
Definition: httpd.h:1116
void ap_method_registry_init(apr_pool_t *p)
void ap_send_error_response(request_rec *r, int recursive_error)
void ap_note_digest_auth_failure(request_rec *r)
const char * ap_select_protocol(conn_rec *c, request_rec *r, server_rec *s, const apr_array_header_t *choices)
apr_status_t ap_get_basic_auth_components(const request_rec *r, const char **username, const char **password)
int int ap_rflush(request_rec *r)
Definition: apr_mmap.h:62
#define AP_DECLARE_HOOK(ret, name, args)
Definition: ap_hooks.h:74
void ap_method_list_add(ap_method_list_t *l, const char *method)
apr_int64_t apr_time_t
Definition: apr_time.h:45
void ap_set_last_modified(request_rec *r)
apr_bucket_brigade * bb
Definition: mod_dav.h:552
HTTP Daemon routines.
AP_DECLARE_DATA ap_filter_rec_t * ap_old_write_func
void ap_setup_make_content_type(apr_pool_t *pool)
apr_port_t default_port(const request_rec *r)
A structure to store information for each virtual server.
Definition: httpd.h:1313
int ap_map_http_request_error(apr_status_t rv, int status)
int note_auth_failure(request_rec *r, const char *auth_type)
Definition: apr_buckets.h:224
ap_condition_e ap_condition_if_unmodified_since(request_rec *r, apr_table_t *headers)
dav_error * src
Definition: mod_dav.h:186
ap_condition_e
Definition: http_protocol.h:177
void ap_note_basic_auth_failure(request_rec *r)
int ap_rvputs(request_rec *r,...) AP_FN_ATTR_SENTINEL
const char * data
Definition: http_protocol.h:937
APR-UTIL Buckets/Bucket Brigades.
apr_status_t ap_rgetline(char **s, apr_size_t n, apr_size_t *read, request_rec *r, int flags, apr_bucket_brigade *bb)
apr_status_t ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, apr_size_t length, apr_size_t *nbytes)
request_rec * ap_read_request(conn_rec *c)
void pre_read_request(request_rec *r, conn_rec *c)
void ap_clear_method_list(ap_method_list_t *l)
void ap_set_accept_ranges(request_rec *r)
int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist)
apr_status_t ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b)
apr_size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, apr_size_t offset, apr_size_t length)
APR MMAP routines.
int ap_setup_client_block(request_rec *r, int read_policy)
#define APR_INLINE
Definition: apr.h:65
AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error
Definition: apr_buckets.h:534
apr_pool_t * p
const char * ap_make_content_type(request_rec *r, const char *type)
void ap_send_interim_response(request_rec *r, int send_headers)
ap_condition_e ap_condition_if_match(request_rec *r, apr_table_t *headers)
apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime)
A structure that represents the current request.
Definition: httpd.h:806
Apache filter library.
Structure for handling HTTP methods.
Definition: httpd.h:651
int ap_rputc(int c, request_rec *r)
#define AP_DECLARE_DATA
Definition: macros.h:15
dav_buffer const char * str
Definition: mod_dav.h:461
apr_bucket * ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p)
int status
Definition: mod_dav.h:141
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
const char * http_scheme(const request_rec *r)
const char * protocol_get(const conn_rec *c)
Definition: apr_buckets.h:131
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_bucket * ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
apr_status_t ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b)
int apr_status_t
Definition: apr_errno.h:44
int ap_rprintf(request_rec *r, const char *fmt,...) __attribute__((format(printf
int ap_method_in_list(ap_method_list_t *l, const char *method)
int ap_rwrite(const void *buf, int nbyte, request_rec *r)
request_rec * r
Definition: mod_dav.h:515
int ap_method_register(apr_pool_t *p, const char *methname)
apr_uint16_t apr_port_t
Definition: apr_network_io.h:257
char * ap_make_etag(request_rec *r, int force_weak)
int ap_get_basic_auth_pw(request_rec *r, const char **pw)
void ap_get_mime_headers(request_rec *r)
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1346
const char * ap_get_status_line(int status)
Definition: http_protocol.h:178
int ap_meets_conditions(request_rec *r)
apr_status_t ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b)
void ap_parse_uri(request_rec *r, const char *uri)
apr_bucket_refcount refcount
Definition: http_protocol.h:933
ap_condition_e ap_condition_if_range(request_rec *r, apr_table_t *headers)
off_t apr_off_t
Definition: apr.h:377
APR Portability Routines.
ap_condition_e ap_condition_if_none_match(request_rec *r, apr_table_t *headers)
Definition: http_protocol.h:181
void ap_finalize_request_protocol(request_rec *r)