📄 http_protocol.h
字号:
/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as * applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */#ifndef APACHE_HTTP_PROTOCOL_H#define APACHE_HTTP_PROTOCOL_H#include "httpd.h"#include "apr_hooks.h"#include "apr_portable.h"#include "apr_mmap.h"#include "apr_buckets.h"#include "util_filter.h"#ifdef __cplusplusextern "C" {#endif/** * @package HTTP protocol handling *//** * This hook allows modules to insert filters for the current error response * @param r the current request * @ingroup hooks */AP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r))/* This is an optimization. We keep a record of the filter_rec that * stores the old_write filter, so that we can avoid strcmp's later. */AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;/* * Prototypes for routines which either talk directly back to the user, * or control the ones that eventually do. *//** * Read a request and fill in the fields. * @param c The current connection * @return The new request_rec */ request_rec *ap_read_request(conn_rec *c);/** * Read the mime-encoded headers. * @param r The current request */AP_DECLARE(void) ap_get_mime_headers(request_rec *r);/** * Optimized version of ap_get_mime_headers() that requires a * temporary brigade to work with * @param r The current request * @param bb temp brigade */AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb);/* Finish up stuff after a request *//** * Called at completion of sending the response. It sends the terminating * protocol information. * @param r The current request * @deffunc void ap_finalize_request_protocol(request_rec *r) */AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);/** * Send error back to client. * @param r The current request * @param recursive_error last arg indicates error status in case we get * an error in the process of trying to deal with an ErrorDocument * to handle some other error. In that case, we print the default * report for the first thing that went wrong, and more briefly report * on the problem with the ErrorDocument. * @deffunc void ap_send_error_response(request_rec *r, int recursive_error) */AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);/* Set last modified header line from the lastmod date of the associated file. * Also, set content length. * * May return an error status, typically HTTP_NOT_MODIFIED (that when the * permit_cache argument is set to one). *//** * Set the content length for this request * @param r The current request * @param length The new content length * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length) */AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);/** * Set the keepalive status for this request * @param r The current request * @return 1 if keepalive can be set, 0 otherwise * @deffunc int ap_set_keepalive(request_rec *r) */AP_DECLARE(int) ap_set_keepalive(request_rec *r);/** * Return the latest rational time from a request/mtime pair. Mtime is * returned unless it's in the future, in which case we return the current time. * @param r The current request * @param mtime The last modified time * @return the latest rational time. * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime) */AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);/** * Build the content-type that should be sent to the client from the * content-type specified. The following rules are followed: * - if type is NULL, type is set to ap_default_type(r) * - if charset adding is disabled, stop processing and return type. * - then, if there are no parameters on type, add the default charset * - return type * @param r The current request * @return The content-type * @deffunc const char *ap_make_content_type(request_rec *r, const char *type); */ AP_DECLARE(const char *) ap_make_content_type(request_rec *r, const char *type);#ifdef CORE_PRIVATE/** * Precompile metadata structures used by ap_make_content_type() * @param r The pool to use for allocations * @deffunc void ap_setup_make_content_type(apr_pool_t *pool) */AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool);#endif /* CORE_PRIVATE *//** * Construct an entity tag from the resource information. If it's a real * file, build in some of the file characteristics. * @param r The current request * @param force_weak Force the entity tag to be weak - it could be modified * again in as short an interval. * @return The entity tag * @deffunc char *ap_make_etag(request_rec *r, int force_weak) */ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);/** * Set the E-tag outgoing header * @param The current request * @deffunc void ap_set_etag(request_rec *r) */AP_DECLARE(void) ap_set_etag(request_rec *r);/** * Set the last modified time for the file being sent * @param r The current request * @deffunc void ap_set_last_modified(request_rec *r) */AP_DECLARE(void) ap_set_last_modified(request_rec *r);/** * Implements condition GET rules for HTTP/1.1 specification. This function * inspects the client headers and determines if the response fulfills * the requirements specified. * @param r The current request * @return OK if the response fulfills the condition GET rules, some * other status code otherwise * @deffunc int ap_meets_conditions(request_rec *r) */AP_DECLARE(int) ap_meets_conditions(request_rec *r);/* Other ways to send stuff at the client. All of these keep track * of bytes_sent automatically. This indirection is intended to make * it a little more painless to slide things like HTTP-NG packetization * underneath the main body of the code later. In the meantime, it lets * us centralize a bit of accounting (bytes_sent). * * These also return the number of bytes written by the call. * They should only be called with a timeout registered, for obvious reaasons. * (Ditto the send_header stuff). *//** * Send an entire file to the client, using sendfile if supported by the * current platform * @param fd The file to send. * @param r The current request * @param offset Offset into the file to start sending. * @param length Amount of data to send * @param nbytes Amount of data actually sent * @deffunc 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); */AP_DECLARE(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);#if APR_HAS_MMAP/** * Send an MMAP'ed file to the client * @param mm The MMAP'ed file to send * @param r The current request * @param offset The offset into the MMAP to start sending * @param length The amount of data to send * @return The number of bytes sent * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length) */AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length);#endif/** * Register a new request method, and return the offset that will be * associated with that method. * * @param p The pool to create registered method numbers from. * @param methname The name of the new method to register. * @return Ab int value representing an offset into a bitmask. */AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);/** * Initialize the method_registry and allocate memory for it. * * @param p Pool to allocate memory for the registry from. */AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);/* * This is a convenience macro to ease with checking a mask * against a method name. */#define AP_METHOD_CHECK_ALLOWED(mask, methname) \ ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))/** * Create a new method list with the specified number of preallocated * slots for extension methods. * * @param p Pointer to a pool in which the structure should be * allocated. * @param nelts Number of preallocated extension slots * @return Pointer to the newly created structure. * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts) */AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts);AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest, ap_method_list_t *src);AP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname, int mnum), void *rec, const ap_method_list_t *ml, ...);AP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname, int mnum), void *rec, const ap_method_list_t *ml, va_list vp);/** * Search for an HTTP method name in an ap_method_list_t structure, and * return true if found. * * @param method String containing the name of the method to check. * @param l Pointer to a method list, such as cmd->methods_limited. * @return 1 if method is in the list, otherwise 0 * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l) */AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);/** * Add an HTTP method name to an ap_method_list_t structure if it isn't * already listed. * * @param method String containing the name of the method to check. * @param l Pointer to a method list, such as cmd->methods_limited. * @return None. * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method) */AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method); /** * Remove an HTTP method name from an ap_method_list_t structure. * * @param l Pointer to a method list, such as cmd->methods_limited. * @param method String containing the name of the method to remove. * @return None. * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method) */AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l, const char *method);/** * Reset a method list to be completely empty. * * @param l Pointer to a method list, such as cmd->methods_limited. * @return None. * @deffunc void ap_clear_method_list(ap_method_list_t *l) */AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l); /** * Set the content type for this request (r->content_type). * @param r The current request * @param ct The new content type * @deffunc void ap_set_content_type(request_rec *r, const char* ct) * @warning This function must be called to set r->content_type in order * for the AddOutputFilterByType directive to work correctly. */AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);/* Hmmm... could macrofy these for now, and maybe forever, though the * definitions of the macros would get a whole lot hairier. *//** * Output one character for this request * @param c the character to output * @param r the current request * @return The number of bytes sent * @deffunc int ap_rputc(int c, request_rec *r) */AP_DECLARE(int) ap_rputc(int c, request_rec *r);/** * Output a string for the current request * @param str The string to output * @param r The current request * @return The number of bytes sent * @deffunc int ap_rputs(const char *str, request_rec *r) */AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);/** * Write a buffer for the current request * @param buf The buffer to write * @param nbyte The number of bytes to send from the buffer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -