116Svbart@nginx.com 216Svbart@nginx.com /* 316Svbart@nginx.com * Copyright (C) NGINX, Inc. 416Svbart@nginx.com * Copyright (C) Valentin V. Bartenev 516Svbart@nginx.com */ 616Svbart@nginx.com 716Svbart@nginx.com #ifndef _NXT_HTTP_PARSER_H_INCLUDED_ 816Svbart@nginx.com #define _NXT_HTTP_PARSER_H_INCLUDED_ 916Svbart@nginx.com 1016Svbart@nginx.com 1116Svbart@nginx.com typedef struct nxt_http_request_parse_s nxt_http_request_parse_t; 1216Svbart@nginx.com typedef struct nxt_http_fields_hash_s nxt_http_fields_hash_t; 1316Svbart@nginx.com 1460Svbart@nginx.com 1560Svbart@nginx.com typedef union { 1660Svbart@nginx.com u_char str[8]; 1760Svbart@nginx.com uint64_t ui64; 1860Svbart@nginx.com } nxt_http_ver_t; 1916Svbart@nginx.com 2016Svbart@nginx.com 2160Svbart@nginx.com typedef struct { 2260Svbart@nginx.com union { 2360Svbart@nginx.com uint8_t str[32]; 2460Svbart@nginx.com uint64_t ui64[4]; 2560Svbart@nginx.com } key; 2660Svbart@nginx.com 2760Svbart@nginx.com nxt_str_t name; 2860Svbart@nginx.com nxt_str_t value; 2960Svbart@nginx.com } nxt_http_field_t; 3016Svbart@nginx.com 3116Svbart@nginx.com 3216Svbart@nginx.com struct nxt_http_request_parse_s { 3360Svbart@nginx.com nxt_int_t (*handler)(nxt_http_request_parse_t *rp, 3460Svbart@nginx.com u_char **pos, u_char *end); 3516Svbart@nginx.com 3660Svbart@nginx.com size_t offset; 3716Svbart@nginx.com 3860Svbart@nginx.com nxt_str_t method; 3916Svbart@nginx.com 4060Svbart@nginx.com u_char *target_start; 4160Svbart@nginx.com u_char *target_end; 4260Svbart@nginx.com u_char *exten_start; 4360Svbart@nginx.com u_char *args_start; 4416Svbart@nginx.com 4560Svbart@nginx.com nxt_http_ver_t version; 4616Svbart@nginx.com 4760Svbart@nginx.com nxt_http_field_t field; 4860Svbart@nginx.com nxt_list_t *fields; 4916Svbart@nginx.com 5016Svbart@nginx.com /* target with "/." */ 5160Svbart@nginx.com unsigned complex_target:1; 5216Svbart@nginx.com /* target with "%" */ 5360Svbart@nginx.com unsigned quoted_target:1; 5416Svbart@nginx.com /* target with " " */ 5560Svbart@nginx.com unsigned space_in_target:1; 5616Svbart@nginx.com /* target with "+" */ 5760Svbart@nginx.com unsigned plus_in_target:1; 5816Svbart@nginx.com }; 5916Svbart@nginx.com 6016Svbart@nginx.com 6160Svbart@nginx.com typedef nxt_int_t (*nxt_http_field_handler_t)(void *ctx, 6260Svbart@nginx.com nxt_http_field_t *field, 6360Svbart@nginx.com uintptr_t data, nxt_log_t *log); 6460Svbart@nginx.com 6560Svbart@nginx.com 6616Svbart@nginx.com typedef struct { 6716Svbart@nginx.com nxt_str_t name; 6816Svbart@nginx.com nxt_http_field_handler_t handler; 6916Svbart@nginx.com uintptr_t data; 7060Svbart@nginx.com } nxt_http_fields_hash_entry_t; 7160Svbart@nginx.com 7260Svbart@nginx.com 7360Svbart@nginx.com nxt_inline nxt_int_t 74*65Sigor@sysoev.ru nxt_http_parse_request_init(nxt_http_request_parse_t *rp, nxt_mp_t *mp) 7560Svbart@nginx.com { 7660Svbart@nginx.com rp->fields = nxt_list_create(mp, 8, sizeof(nxt_http_field_t)); 7760Svbart@nginx.com if (nxt_slow_path(rp->fields == NULL)){ 7860Svbart@nginx.com return NXT_ERROR; 7960Svbart@nginx.com } 8060Svbart@nginx.com 8160Svbart@nginx.com return NXT_OK; 8260Svbart@nginx.com } 8316Svbart@nginx.com 8416Svbart@nginx.com 8516Svbart@nginx.com nxt_int_t nxt_http_parse_request(nxt_http_request_parse_t *rp, 8616Svbart@nginx.com nxt_buf_mem_t *b); 8760Svbart@nginx.com 8860Svbart@nginx.com nxt_http_fields_hash_t *nxt_http_fields_hash_create( 89*65Sigor@sysoev.ru nxt_http_fields_hash_entry_t *entries, nxt_mp_t *mp); 9060Svbart@nginx.com nxt_http_fields_hash_entry_t *nxt_http_fields_hash_lookup( 9160Svbart@nginx.com nxt_http_fields_hash_t *hash, nxt_http_field_t *field); 9260Svbart@nginx.com 9360Svbart@nginx.com nxt_int_t nxt_http_fields_process(nxt_list_t *fields, 9460Svbart@nginx.com nxt_http_fields_hash_t *hash, void *ctx, nxt_log_t *log); 9516Svbart@nginx.com 9616Svbart@nginx.com 9716Svbart@nginx.com #endif /* _NXT_HTTP_PARSER_H_INCLUDED_ */ 98