1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __mod_h2__h2_from_h1__
17 #define __mod_h2__h2_from_h1__
20 * h2_from_h1 parses a HTTP/1.1 response into
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.
26 * All data is allocated from the stream memory pool.
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.
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 */
43 typedef struct h2_from_h1 h2_from_h1;
47 h2_from_h1_state_t state;
49 apr_bucket_brigade *bb;
51 apr_size_t content_length;
55 apr_array_header_t *hlines;
57 struct h2_response *response;
61 typedef void h2_from_h1_state_change_cb(struct h2_from_h1 *resp,
62 h2_from_h1_state_t prevstate,
65 h2_from_h1 *h2_from_h1_create(int stream_id, apr_pool_t *pool);
67 apr_status_t h2_from_h1_destroy(h2_from_h1 *response);
69 void h2_from_h1_set_state_change_cb(h2_from_h1 *from_h1,
70 h2_from_h1_state_change_cb *callback,
73 apr_status_t h2_from_h1_read_response(h2_from_h1 *from_h1,
74 ap_filter_t* f, apr_bucket_brigade* bb);
76 struct h2_response *h2_from_h1_get_response(h2_from_h1 *from_h1);
78 h2_from_h1_state_t h2_from_h1_get_state(h2_from_h1 *from_h1);
80 apr_status_t h2_response_output_filter(ap_filter_t *f, apr_bucket_brigade *bb);
82 #endif /* defined(__mod_h2__h2_from_h1__) */