]> granicus.if.org Git - apache/blob - modules/http2/h2_from_h1.h
merged latest changes in 2.4.x
[apache] / modules / http2 / h2_from_h1.h
1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef __mod_h2__h2_from_h1__
17 #define __mod_h2__h2_from_h1__
18
19 /**
20  * h2_from_h1 parses a HTTP/1.1 response into
21  * - response status
22  * - a list of header values
23  * - a series of bytes that represent the response body alone, without
24  *   any meta data, such as inserted by chunked transfer encoding.
25  *
26  * All data is allocated from the stream memory pool. 
27  *
28  * Again, see comments in h2_request: ideally we would take the headers
29  * and status from the httpd structures instead of parsing them here, but
30  * we need to have all handlers and filters involved in request/response
31  * processing, so this seems to be the way for now.
32  */
33
34 typedef enum {
35     H2_RESP_ST_STATUS_LINE, /* parsing http/1 status line */
36     H2_RESP_ST_HEADERS,     /* parsing http/1 response headers */
37     H2_RESP_ST_BODY,        /* transferring response body */
38     H2_RESP_ST_DONE         /* complete response converted */
39 } h2_from_h1_state_t;
40
41 struct h2_response;
42
43 typedef struct h2_from_h1 h2_from_h1;
44
45 struct h2_from_h1 {
46     int stream_id;
47     h2_from_h1_state_t state;
48     apr_pool_t *pool;
49     apr_bucket_brigade *bb;
50     
51     apr_size_t content_length;
52     int chunked;
53     
54     const char *status;
55     apr_array_header_t *hlines;
56     
57     struct h2_response *response;
58 };
59
60
61 typedef void h2_from_h1_state_change_cb(struct h2_from_h1 *resp,
62                                          h2_from_h1_state_t prevstate,
63                                          void *cb_ctx);
64
65 h2_from_h1 *h2_from_h1_create(int stream_id, apr_pool_t *pool);
66
67 apr_status_t h2_from_h1_destroy(h2_from_h1 *response);
68
69 void h2_from_h1_set_state_change_cb(h2_from_h1 *from_h1,
70                                      h2_from_h1_state_change_cb *callback,
71                                      void *cb_ctx);
72
73 apr_status_t h2_from_h1_read_response(h2_from_h1 *from_h1,
74                                       ap_filter_t* f, apr_bucket_brigade* bb);
75
76 struct h2_response *h2_from_h1_get_response(h2_from_h1 *from_h1);
77
78 h2_from_h1_state_t h2_from_h1_get_state(h2_from_h1 *from_h1);
79
80 apr_status_t h2_response_output_filter(ap_filter_t *f, apr_bucket_brigade *bb);
81
82 #endif /* defined(__mod_h2__h2_from_h1__) */