diff options
Diffstat (limited to 'include/http_protocol.h')
-rw-r--r-- | include/http_protocol.h | 104 |
1 files changed, 100 insertions, 4 deletions
diff --git a/include/http_protocol.h b/include/http_protocol.h index 11c7b2d..94c481e 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -54,6 +54,13 @@ AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func; */ /** + * Read an empty request and set reasonable defaults. + * @param c The current connection + * @return The new request_rec + */ +AP_DECLARE(request_rec *) ap_create_request(conn_rec *c); + +/** * Read a request and fill in the fields. * @param c The current connection * @return The new request_rec @@ -61,6 +68,20 @@ AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func; request_rec *ap_read_request(conn_rec *c); /** + * Parse and validate the request line. + * @param r The current request + * @return 1 on success, 0 on failure + */ +AP_DECLARE(int) ap_parse_request_line(request_rec *r); + +/** + * Validate the request header and select vhost. + * @param r The current request + * @return 1 on success, 0 on failure + */ +AP_DECLARE(int) ap_check_request_header(request_rec *r); + +/** * Read the mime-encoded headers. * @param r The current request */ @@ -75,6 +96,13 @@ AP_DECLARE(void) ap_get_mime_headers(request_rec *r); AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb); +/** + * Run post_read_request hook and validate. + * @param r The current request + * @return OK or HTTP_... + */ +AP_DECLARE(int) ap_post_read_request(request_rec *r); + /* Finish up stuff after a request */ /** @@ -145,6 +173,27 @@ AP_DECLARE(const char *) ap_make_content_type(request_rec *r, */ AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool); +/** A structure with the ingredients for a file based etag */ +typedef struct etag_rec etag_rec; + +/** + * @brief A structure with the ingredients for a file based etag + */ +struct etag_rec { + /** Optional vary list validator */ + const char *vlist_validator; + /** Time when the request started */ + apr_time_t request_time; + /** finfo.protection (st_mode) set to zero if no such file */ + apr_finfo_t *finfo; + /** File pathname used when generating a digest */ + const char *pathname; + /** File descriptor used when generating a digest */ + apr_file_t *fd; + /** Force a non-digest etag to be weak */ + int force_weak; +}; + /** * Construct an entity tag from the resource information. If it's a real * file, build in some of the file characteristics. @@ -156,12 +205,27 @@ AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool); AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak); /** + * Construct an entity tag from information provided in the etag_rec + * structure. + * @param r The current request + * @param er The etag record, containing ingredients for the etag. + */ +AP_DECLARE(char *) ap_make_etag_ex(request_rec *r, etag_rec *er); + +/** * Set the E-tag outgoing header * @param r The current request */ AP_DECLARE(void) ap_set_etag(request_rec *r); /** + * Set the E-tag outgoing header, with the option of forcing a strong ETag. + * @param r The current request + * @param fd The file descriptor + */ +AP_DECLARE(void) ap_set_etag_fd(request_rec *r, apr_file_t *fd); + +/** * Set the last modified time for the file being sent * @param r The current request */ @@ -411,7 +475,27 @@ AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); */ static APR_INLINE int ap_rputs(const char *str, request_rec *r) { - return ap_rwrite(str, (int)strlen(str), r); + apr_size_t len; + + len = strlen(str); + + for (;;) { + if (len <= INT_MAX) { + return ap_rwrite(str, (int)len, r); + } + else { + int rc; + + rc = ap_rwrite(str, INT_MAX, r); + if (rc < 0) { + return rc; + } + else { + str += INT_MAX; + len -= INT_MAX; + } + } + } } /** @@ -466,6 +550,17 @@ AP_DECLARE(int) ap_index_of_response(int status); */ AP_DECLARE(const char *) ap_get_status_line(int status); +/** + * Return the Status-Line for a given status code (excluding the + * HTTP-Version field). If an invalid status code is passed, + * "500 Internal Server Error" will be returned, whereas an unknown + * status will be returned like "xxx Status xxx". + * @param p The pool to allocate from when status is unknown + * @param status The HTTP status code + * @return The Status-Line + */ +AP_DECLARE(const char *) ap_get_status_line_ex(apr_pool_t *p, int status); + /* Reading a block of data from the client connection (e.g., POST arg) */ /** @@ -733,7 +828,7 @@ AP_DECLARE_HOOK(const char *,http_scheme,(const request_rec *r)) AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r)) -#define AP_PROTOCOL_HTTP1 "http/1.1" +#define AP_PROTOCOL_HTTP1 "http/1.1" /** * Determine the list of protocols available for a connection/request. This may @@ -798,8 +893,7 @@ AP_DECLARE_HOOK(int,protocol_propose,(conn_rec *c, request_rec *r, * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected - * @param choices A list of protocol identifiers, normally the clients whishes - * @param proposals the list of protocol identifiers proposed by the hooks + * @param protocol The protocol identifier we try to switch to * @return OK or DECLINED * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with @@ -1015,6 +1109,8 @@ AP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub_r); */ AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers); + + #ifdef __cplusplus } #endif |