📄 http.h
字号:
* Per-transaction per direction status values (32 bits) */#define TRANS_ERR 0x1#define TRANS_INCOMPLETE 0x2#define TRANS_FINISHED 0x4 /* but may not be complete! (e.g not-modified)*/#define TRANS_CHUNKED 0x10 /* used chunked transfer encoding */#define TRANS_HDR_FRAG 0x20 /* header fragmented */#define TRANS_RESYNCHED 0x100 /* not seen some octets - but resynched */#define TRANS_LOST_SYNCH 0x200 /* lost octets - synch not recovered */#define TRANS_OBJ_INTERRUPTED 0x800#define TRANS_SERVER_CONT 0x1000 /* have seen continue from server */#define TRANS_LINKS_CHARS_EX 0x10000 /* run out of buffers *//* Denote dummies collecting octets after loss of synch or error */#define TRANS_DUMMY_UNSYNCH 0x10000000#define TRANS_DUMMY_ERR 0x20000000/* Denotes transaction valid for this direction */#define TRANS_VAL 0x40000000#define TRANS_TIMING_PATCHED 0x80000000/* * Recursion flag values for HTTP hdr parsing */#define RECURSING 1#define NOT_RECURSING 0/* * HTTP Version definitions */#define HTTP_VERS_0_9 0x1#define HTTP_VERS_1_0 0x2#define HTTP_VERS_1_1 0x4#define HTTP_VERS_SERVER_SHIFT 3#define HTTP_CLIENT_VERS0_9 HTTP_VERS_0_9#define HTTP_CLIENT_VERS1_0 HTTP_VERS_1_0#define HTTP_CLIENT_VERS1_1 HTTP_VERS_1_1#define HTTP_SERV_VERS0_9 (HTTP_VERS_0_9 * 8)#define HTTP_SERV_VERS1_0 (HTTP_VERS_1_0 * 8)#define HTTP_SERV_VERS1_1 (HTTP_VERS_1_1 * 8)#define HTTP_CLIENT_VERS (HTTP_CLIENT_VERS1_0 | HTTP_CLIENT_VERS1_1 | HTTP_CLIENT_VERS0_9)#define HTTP_SERV_VERS (HTTP_SERV_VERS1_0 | HTTP_SERV_VERS1_1 | HTTP_SERV_VERS0_9)/* * HTTP request methods (8 bits) */#define HTTP_METHOD_UNKNOWN 0#define HTTP_METHOD_GET 1#define HTTP_METHOD_HEAD 2#define HTTP_METHOD_POST 3#define HTTP_METHOD_OPTIONS 4#define HTTP_METHOD_PUT 5#define HTTP_METHOD_DELETE 6#define HTTP_METHOD_TRACE 7#define HTTP_METHOD_CONNECT 8#define HTTP_METHOD_MOVE 9#define HTTP_METHOD_BMOVE 10#define HTTP_METHOD_PROPFIND 11#define HTTP_METHOD_PROPPATCH 12#define HTTP_METHOD_UNRECOGNISED 255#define HTTP_SERVER_RETCODE_UNKNOWN 0#ifndef SWIG/* * defn's for interrupted chunk decoding */#define CHUNK_NO_STATE 0x0#define CHUNK_CLEAR_CR 0x1#define CHUNK_CLEAR_NL 0x2#define CHUNK_CLEAR_CR_HI 0x4#define CHUNK_CLEAR_NL_HI 0x8#define CHUNK_CLEAR_EXT 0x10#define CHUNK_CHUNK_DONE 0x100#define CHUNK_LEN_DECODED 0x200#define CHUNK_IN_LEN_DECODE 0x400#define CHUNK_STATE_LOW 0xff#define CHUNK_STATE_HIGH 0x00ffff00#define CHUNKEND_INDX 0xff000000#define CLEAR_CHUNK_DELIM(pp, sp, err) \MACRO_BEGIN \ while (pp->len && (*sp & CHUNK_STATE_LOW)) \ { \ if (*sp & CHUNK_CLEAR_EXT) \ { \ while (*(pp->buf) != '\r' && pp->len) \ ADJUST(pp, sizeof(char)); \ if (pp->len) \ *sp &= ~CHUNK_CLEAR_EXT; \ continue; \ } \ if (*sp & CHUNK_CLEAR_CR) \ { \ if (*pp->buf == '\r') \ { \ ADJUST(pp, sizeof(char)); \ *sp &= ~CHUNK_CLEAR_CR; \ } \ else \ { \ return err; \ } \ continue; \ } \ if (*sp & CHUNK_CLEAR_NL) \ { \ if (*pp->buf == '\n') \ { \ ADJUST(pp, sizeof(char)); \ *sp &= ~CHUNK_CLEAR_NL; \ } \ else \ { \ return err; \ } \ continue; \ } \ } \ if (!(*sp & CHUNK_STATE_LOW)) \ *sp = CHUNK_NO_STATE; \MACRO_END/* * Pull buffer up to parse endpoint buff */#define ADJ_BUF(pp, buff) \MACRO_BEGIN \ (pp)->len -= (int)((buff) - (pp)->buf); \ (pp)->buf = (buff); \MACRO_END/* * Clear HTTP header line past CR/NL (or just NL) - jump on buffer exhaustion */#define CLEAR_LINE(pp) \MACRO_BEGIN \ while ((pp)->len > 0 && *((pp)->buf) != '\n') \ { \ (pp)->len--; \ (pp)->buf++; \ } \ if ((pp)->len < sizeof(char)) \ { \ goto interrupted; \ } \ ADJUST((pp), sizeof(char)); \MACRO_END/* * Clear HTTP header line past CR/NL (or just NL) - return error on buffer * exhaustion */#define CLEAR_LINE_RET(pp, way) \MACRO_BEGIN \ while ((pp)->len > 0 && *((pp)->buf) != '\n') \ { \ (pp)->len--; \ (pp)->buf++; \ } \ if ((pp)->len < sizeof(char)) \ { \ return (way) == SERVER ? HTTP_SERV_ERR_TRUNCHDR : HTTP_CLI_ERR_TRUNCHDR;\ } \ ADJUST((pp), sizeof(char)); \MACRO_END/* * data will be interpreted according to error */#define HTTP_ASSERT(expr, pp, tconnp, error, way, data, repair) \MACRO_BEGIN \ if (!(expr)) \ { \ fprintf(stderr, "XXX HTTP-ASSERT_FAIL %s XXX\n", http_err_string(error));\ http_error((tconnp), (pp), (error), (way), (data));\ repair; \ return (error); \ } \MACRO_END#define DONT_CLEAR 0#define DO_CLEAR 1#define CLEAR_VALUE(buffer) \MACRO_BEGIN \ while (isprint(*(buffer)->buf)) \ ADJUST((buffer), sizeof(char)); \ if ((buffer)->len <= 0) \ return HTTP_SERV_ERR_TRUNCHDR; \MACRO_END/* * swallow spaces */#define CLEAR_SPACE(pp, way) \MACRO_BEGIN \ while ((pp)->len > 0 && *((pp)->buf) == ' ') \ { \ (pp)->len--; \ (pp)->buf++; \ } \ if ((pp)->len == 0) \ return (way) == SERVER ? HTTP_SERV_ERR_TRUNCHDR : HTTP_CLI_ERR_TRUNCHDR; \MACRO_END/* * swallow comma */#define CLEAR_COMMA(pp) \MACRO_BEGIN \ if ((pp)->len > 0 && *((pp)->buf) == ',') \ { \ (pp)->len--; \ (pp)->buf++; \ } \ if ((pp)->len == 0) \ return way == SERVER ? HTTP_SERV_ERR_TRUNCHDR : HTTP_CLI_ERR_TRUNCHDR; \MACRO_ENDstruct tcp_conn; /* forward */struct tcp_heldpkt; /* forward */struct tcp_simplex_flow; /* forward *//* * http.c */void tcp_http_open(prec_t *pp, struct tcp_conn *tconnp, int way, unsigned char flags);void tcp_http_close(prec_t *pp, struct tcp_conn *tconnp, int way, unsigned char flags);void tcp_http_dump(struct tcp_conn *tconnp);void get_chunk_len(prec_t *pp, unsigned int *lenp, int *statep);int body_de_chunk(prec_t *pp, struct tcp_conn *tconnp, short code, int way); int get_hdrline(prec_t *pp, struct tcp_conn *tconnp, int way, char *top, unsigned char *charlen);int save_interrupted_hdr(char *start, int len, http_hdr_parse_state_t *ps, int way);int get_encoding_type(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);int get_content_length(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);int get_http_version(prec_t *pp, int way);int tcp_http_pkt(prec_t *pp, struct tcp_conn *tconnp, int way);int get_connection_type(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);int new_http_trans(struct tcp_conn *tconnp, int way);void trans_complete(struct tcp_conn *tconnp, int way);void free_trans(struct tcp_conn *tconnp);int tcp_http_sync(struct tcp_heldpkt *hpp, struct tcp_conn *tconnp, struct tcp_simplex_flow *tsp, unsigned int gap, int way, unsigned int tm);struct tcp_conn; /* Forward*/int get_trailer_fields(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);struct serv_control;extern struct serv_control tcp_http_serv_control;/* * http_req.c */int parse_req_hdr(prec_t *pp, struct tcp_conn *tconnp, int recursing);int parse_req_body(prec_t *pp, struct tcp_conn *tconnp, int len);int get_referer(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);int get_te_perm(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);/* * http_rep.c */int get_refresh(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);int get_location(prec_t *pp, struct tcp_conn *tconnp, int way, char *dummy, unsigned char *anotherdummy);int parse_rep_hdr(prec_t *pp, struct tcp_conn *tconnp, int recursing);int do_rep_body(prec_t *pp, struct tcp_conn *tconnp, int len, short code);unsigned short fold_body_cksm(struct tcp_conn *tconnp);void dump_object(prec_t *pp, struct tcp_conn *tconnp, int len);/* * parse_http_fields.c */int parse_http_fields(prec_t *pp, struct tcp_conn *tconnp, int way);/* * error.c */extern char *prog;void http_error(struct tcp_conn *tconnp, prec_t *pp, int err, int way, char *data);/* * tcp.c */void free_held_list(struct tcp_conn *tconnp);void tconn_cleanup(struct tcp_conn *tconnp, int why);#ifdef __linux__/* * i386-csum.S */unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);#endif /* #ifdef __linux__ */#endif /* ifndef SWIG *//****************************************************************************/#endif /* _HTTP_H *//* * end http.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -