1 
2 #ifndef _NGX_AJP_HANDLER_H_INCLUDED_
3 #define _NGX_AJP_HANDLER_H_INCLUDED_
4 
5 
6 #include <ngx_config.h>
7 #include <ngx_core.h>
8 #include <ngx_http.h>
9 #include <ngx_http_ajp_module.h>
10 #include <ngx_http_ajp.h>
11 
12 
13 typedef enum {
14     ngx_http_ajp_st_init_state = 0,
15     ngx_http_ajp_st_forward_request_sent,
16     ngx_http_ajp_st_request_body_data_sending,
17     ngx_http_ajp_st_request_send_all_done,
18     ngx_http_ajp_st_response_recv_headers,
19     ngx_http_ajp_st_response_parse_headers_done,
20     ngx_http_ajp_st_response_headers_sent,
21     ngx_http_ajp_st_response_body_data_sending,
22     ngx_http_ajp_st_response_end
23 } ngx_http_ajp_state_e;
24 
25 typedef enum {
26     ngx_http_ajp_pst_init_state = 0,
27     ngx_http_ajp_pst_preamble1,
28     ngx_http_ajp_pst_preamble2,
29     ngx_http_ajp_pst_payload_length_hi,
30     ngx_http_ajp_pst_payload_length_lo,
31     ngx_http_ajp_pst_end_response,
32     ngx_http_ajp_pst_data_length_hi,
33     ngx_http_ajp_pst_data_length_lo
34 } ngx_http_ajp_packet_state_e;
35 
36 typedef struct {
37     ngx_http_ajp_state_e           state;
38     ngx_http_ajp_packet_state_e    pstate;
39 
40     u_char                         length_hi;
41     /* record the response body chunk packet's length */
42     size_t                         length;
43 
44     /* extra zero byte in each ajp data packet */
45     ngx_uint_t                     extra_zero_byte;
46 
47     /* reuse in sending request and receiving response */
48     ajp_msg_t                      msg;
49 
50     /* save the left request body buffers */
51     ngx_chain_t                   *body;
52 
53     ngx_uint_t                     ajp_reuse; /* unsigned :1 */
54 
55 } ngx_http_ajp_ctx_t;
56 
57 
58 ngx_int_t ngx_http_ajp_handler(ngx_http_request_t *r);
59 
60 
61 #endif /* _NGX_AJP_HANDLER_H_INCLUDED_ */
62