summaryrefslogtreecommitdiffstats
path: root/modules/http2/h2_headers.h
blob: 3d78dc357f741419fcd833a44d5238ee4310ba36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __mod_h2__h2_headers__
#define __mod_h2__h2_headers__

#include "h2.h"

#if !AP_HAS_RESPONSE_BUCKETS

struct h2_bucket_beam;

typedef struct h2_headers h2_headers;
struct h2_headers {
    int         status;
    apr_table_t *headers;
    apr_table_t *notes;
    apr_off_t   raw_bytes;      /* RAW network bytes that generated this request - if known. */
};


extern const apr_bucket_type_t h2_bucket_type_headers;

#define H2_BUCKET_IS_HEADERS(e)     (e->type == &h2_bucket_type_headers)

apr_bucket * h2_bucket_headers_make(apr_bucket *b, h2_headers *r); 

apr_bucket * h2_bucket_headers_create(apr_bucket_alloc_t *list, 
                                       h2_headers *r);
                                       
h2_headers *h2_bucket_headers_get(apr_bucket *b);

/**
 * Create the headers from the given status and headers
 * @param status the headers status
 * @param header the headers of the headers
 * @param notes  the notes carried by the headers
 * @param raw_bytes the raw network bytes (if known) used to transmit these
 * @param pool the memory pool to use
 */
h2_headers *h2_headers_create(int status, const apr_table_t *header,
                              const apr_table_t *notes, apr_off_t raw_bytes,
                              apr_pool_t *pool);

/**
 * Create the headers from the given request_rec.
 * @param r the request record which was processed
 * @param status the headers status
 * @param header the headers of the headers
 * @param pool the memory pool to use
 */
h2_headers *h2_headers_rcreate(request_rec *r, int status, 
                               const apr_table_t *header, apr_pool_t *pool);

/**
 * Copy the headers into another pool. This will not copy any
 * header strings.
 */
h2_headers *h2_headers_copy(apr_pool_t *pool, h2_headers *h);

/**
 * Clone the headers into another pool. This will also clone any
 * header strings.
 */
h2_headers *h2_headers_clone(apr_pool_t *pool, h2_headers *h);

/**
 * Create the headers for the given error.
 * @param type the error code
 * @param req the original h2_request
 * @param pool the memory pool to use
 */
h2_headers *h2_headers_die(apr_status_t type,
                           const struct h2_request *req, apr_pool_t *pool);

int h2_headers_are_final_response(h2_headers *headers);

/**
 * Give the number of bytes of all contained header strings.
 */
apr_size_t h2_headers_length(h2_headers *headers);

/**
 * For H2HEADER buckets, return the length of all contained header strings.
 * For all other buckets, return 0.
 */
apr_size_t h2_bucket_headers_headers_length(apr_bucket *b);

apr_bucket *h2_bucket_headers_clone(apr_bucket *b, apr_pool_t *pool,
                                    apr_bucket_alloc_t *list);

#endif /* !AP_HAS_RESPONSE_BUCKETS */

#endif /* defined(__mod_h2__h2_headers__) */