Path: blob/master/Utilities/cmnghttp2/lib/nghttp2_helper.c
3153 views
/*1* nghttp2 - HTTP/2 C Library2*3* Copyright (c) 2012 Tatsuhiro Tsujikawa4*5* Permission is hereby granted, free of charge, to any person obtaining6* a copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sublicense, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice shall be14* included in all copies or substantial portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND19* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE20* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION21* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION22* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.23*/24#include "nghttp2_helper.h"2526#include <assert.h>27#include <string.h>2829#include "nghttp2_net.h"3031void nghttp2_put_uint16be(uint8_t *buf, uint16_t n) {32uint16_t x = htons(n);33memcpy(buf, &x, sizeof(uint16_t));34}3536void nghttp2_put_uint32be(uint8_t *buf, uint32_t n) {37uint32_t x = htonl(n);38memcpy(buf, &x, sizeof(uint32_t));39}4041uint16_t nghttp2_get_uint16(const uint8_t *data) {42uint16_t n;43memcpy(&n, data, sizeof(uint16_t));44return ntohs(n);45}4647uint32_t nghttp2_get_uint32(const uint8_t *data) {48uint32_t n;49memcpy(&n, data, sizeof(uint32_t));50return ntohl(n);51}5253/* Generated by gendowncasetbl.py */54static const uint8_t DOWNCASE_TBL[] = {550 /* NUL */, 1 /* SOH */, 2 /* STX */, 3 /* ETX */,564 /* EOT */, 5 /* ENQ */, 6 /* ACK */, 7 /* BEL */,578 /* BS */, 9 /* HT */, 10 /* LF */, 11 /* VT */,5812 /* FF */, 13 /* CR */, 14 /* SO */, 15 /* SI */,5916 /* DLE */, 17 /* DC1 */, 18 /* DC2 */, 19 /* DC3 */,6020 /* DC4 */, 21 /* NAK */, 22 /* SYN */, 23 /* ETB */,6124 /* CAN */, 25 /* EM */, 26 /* SUB */, 27 /* ESC */,6228 /* FS */, 29 /* GS */, 30 /* RS */, 31 /* US */,6332 /* SPC */, 33 /* ! */, 34 /* " */, 35 /* # */,6436 /* $ */, 37 /* % */, 38 /* & */, 39 /* ' */,6540 /* ( */, 41 /* ) */, 42 /* * */, 43 /* + */,6644 /* , */, 45 /* - */, 46 /* . */, 47 /* / */,6748 /* 0 */, 49 /* 1 */, 50 /* 2 */, 51 /* 3 */,6852 /* 4 */, 53 /* 5 */, 54 /* 6 */, 55 /* 7 */,6956 /* 8 */, 57 /* 9 */, 58 /* : */, 59 /* ; */,7060 /* < */, 61 /* = */, 62 /* > */, 63 /* ? */,7164 /* @ */, 97 /* A */, 98 /* B */, 99 /* C */,72100 /* D */, 101 /* E */, 102 /* F */, 103 /* G */,73104 /* H */, 105 /* I */, 106 /* J */, 107 /* K */,74108 /* L */, 109 /* M */, 110 /* N */, 111 /* O */,75112 /* P */, 113 /* Q */, 114 /* R */, 115 /* S */,76116 /* T */, 117 /* U */, 118 /* V */, 119 /* W */,77120 /* X */, 121 /* Y */, 122 /* Z */, 91 /* [ */,7892 /* \ */, 93 /* ] */, 94 /* ^ */, 95 /* _ */,7996 /* ` */, 97 /* a */, 98 /* b */, 99 /* c */,80100 /* d */, 101 /* e */, 102 /* f */, 103 /* g */,81104 /* h */, 105 /* i */, 106 /* j */, 107 /* k */,82108 /* l */, 109 /* m */, 110 /* n */, 111 /* o */,83112 /* p */, 113 /* q */, 114 /* r */, 115 /* s */,84116 /* t */, 117 /* u */, 118 /* v */, 119 /* w */,85120 /* x */, 121 /* y */, 122 /* z */, 123 /* { */,86124 /* | */, 125 /* } */, 126 /* ~ */, 127 /* DEL */,87128 /* 0x80 */, 129 /* 0x81 */, 130 /* 0x82 */, 131 /* 0x83 */,88132 /* 0x84 */, 133 /* 0x85 */, 134 /* 0x86 */, 135 /* 0x87 */,89136 /* 0x88 */, 137 /* 0x89 */, 138 /* 0x8a */, 139 /* 0x8b */,90140 /* 0x8c */, 141 /* 0x8d */, 142 /* 0x8e */, 143 /* 0x8f */,91144 /* 0x90 */, 145 /* 0x91 */, 146 /* 0x92 */, 147 /* 0x93 */,92148 /* 0x94 */, 149 /* 0x95 */, 150 /* 0x96 */, 151 /* 0x97 */,93152 /* 0x98 */, 153 /* 0x99 */, 154 /* 0x9a */, 155 /* 0x9b */,94156 /* 0x9c */, 157 /* 0x9d */, 158 /* 0x9e */, 159 /* 0x9f */,95160 /* 0xa0 */, 161 /* 0xa1 */, 162 /* 0xa2 */, 163 /* 0xa3 */,96164 /* 0xa4 */, 165 /* 0xa5 */, 166 /* 0xa6 */, 167 /* 0xa7 */,97168 /* 0xa8 */, 169 /* 0xa9 */, 170 /* 0xaa */, 171 /* 0xab */,98172 /* 0xac */, 173 /* 0xad */, 174 /* 0xae */, 175 /* 0xaf */,99176 /* 0xb0 */, 177 /* 0xb1 */, 178 /* 0xb2 */, 179 /* 0xb3 */,100180 /* 0xb4 */, 181 /* 0xb5 */, 182 /* 0xb6 */, 183 /* 0xb7 */,101184 /* 0xb8 */, 185 /* 0xb9 */, 186 /* 0xba */, 187 /* 0xbb */,102188 /* 0xbc */, 189 /* 0xbd */, 190 /* 0xbe */, 191 /* 0xbf */,103192 /* 0xc0 */, 193 /* 0xc1 */, 194 /* 0xc2 */, 195 /* 0xc3 */,104196 /* 0xc4 */, 197 /* 0xc5 */, 198 /* 0xc6 */, 199 /* 0xc7 */,105200 /* 0xc8 */, 201 /* 0xc9 */, 202 /* 0xca */, 203 /* 0xcb */,106204 /* 0xcc */, 205 /* 0xcd */, 206 /* 0xce */, 207 /* 0xcf */,107208 /* 0xd0 */, 209 /* 0xd1 */, 210 /* 0xd2 */, 211 /* 0xd3 */,108212 /* 0xd4 */, 213 /* 0xd5 */, 214 /* 0xd6 */, 215 /* 0xd7 */,109216 /* 0xd8 */, 217 /* 0xd9 */, 218 /* 0xda */, 219 /* 0xdb */,110220 /* 0xdc */, 221 /* 0xdd */, 222 /* 0xde */, 223 /* 0xdf */,111224 /* 0xe0 */, 225 /* 0xe1 */, 226 /* 0xe2 */, 227 /* 0xe3 */,112228 /* 0xe4 */, 229 /* 0xe5 */, 230 /* 0xe6 */, 231 /* 0xe7 */,113232 /* 0xe8 */, 233 /* 0xe9 */, 234 /* 0xea */, 235 /* 0xeb */,114236 /* 0xec */, 237 /* 0xed */, 238 /* 0xee */, 239 /* 0xef */,115240 /* 0xf0 */, 241 /* 0xf1 */, 242 /* 0xf2 */, 243 /* 0xf3 */,116244 /* 0xf4 */, 245 /* 0xf5 */, 246 /* 0xf6 */, 247 /* 0xf7 */,117248 /* 0xf8 */, 249 /* 0xf9 */, 250 /* 0xfa */, 251 /* 0xfb */,118252 /* 0xfc */, 253 /* 0xfd */, 254 /* 0xfe */, 255 /* 0xff */,119};120121void nghttp2_downcase(uint8_t *s, size_t len) {122size_t i;123for (i = 0; i < len; ++i) {124s[i] = DOWNCASE_TBL[s[i]];125}126}127128/*129* local_window_size130* ^ *131* | * recv_window_size132* | * * ^133* | * * |134* 0+++++++++135* | * * \136* | * * | This rage is hidden in flow control. But it must be137* v * * / kept in order to restore it when window size is enlarged.138* recv_reduction139* (+ for negative direction)140*141* recv_window_size could be negative if we decrease142* local_window_size more than recv_window_size:143*144* local_window_size145* ^ *146* | *147* | *148* 0++++++++149* | * ^ recv_window_size (negative)150* | * |151* v * *152* recv_reduction153*/154int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,155int32_t *recv_window_size_ptr,156int32_t *recv_reduction_ptr,157int32_t *delta_ptr) {158if (*delta_ptr > 0) {159int32_t recv_reduction_delta;160int32_t delta;161int32_t new_recv_window_size =162nghttp2_max(0, *recv_window_size_ptr) - *delta_ptr;163164if (new_recv_window_size >= 0) {165*recv_window_size_ptr = new_recv_window_size;166return 0;167}168169delta = -new_recv_window_size;170171/* The delta size is strictly more than received bytes. Increase172local_window_size by that difference |delta|. */173if (*local_window_size_ptr > NGHTTP2_MAX_WINDOW_SIZE - delta) {174return NGHTTP2_ERR_FLOW_CONTROL;175}176*local_window_size_ptr += delta;177/* If there is recv_reduction due to earlier window_size178reduction, we have to adjust it too. */179recv_reduction_delta = nghttp2_min(*recv_reduction_ptr, delta);180*recv_reduction_ptr -= recv_reduction_delta;181if (*recv_window_size_ptr < 0) {182*recv_window_size_ptr += recv_reduction_delta;183} else {184/* If *recv_window_size_ptr > 0, then those bytes are going to185be returned to the remote peer (by WINDOW_UPDATE with the186adjusted *delta_ptr), so it is effectively 0 now. We set to187*recv_reduction_delta, because caller does not take into188account it in *delta_ptr. */189*recv_window_size_ptr = recv_reduction_delta;190}191/* recv_reduction_delta must be paid from *delta_ptr, since it was192added in window size reduction (see below). */193*delta_ptr -= recv_reduction_delta;194195return 0;196}197198if (*local_window_size_ptr + *delta_ptr < 0 ||199*recv_window_size_ptr < INT32_MIN - *delta_ptr ||200*recv_reduction_ptr > INT32_MAX + *delta_ptr) {201return NGHTTP2_ERR_FLOW_CONTROL;202}203/* Decreasing local window size. Note that we achieve this without204noticing to the remote peer. To do this, we cut205recv_window_size by -delta. This means that we don't send206WINDOW_UPDATE for -delta bytes. */207*local_window_size_ptr += *delta_ptr;208*recv_window_size_ptr += *delta_ptr;209*recv_reduction_ptr -= *delta_ptr;210*delta_ptr = 0;211212return 0;213}214215int nghttp2_increase_local_window_size(int32_t *local_window_size_ptr,216int32_t *recv_window_size_ptr,217int32_t *recv_reduction_ptr,218int32_t *delta_ptr) {219int32_t recv_reduction_delta;220int32_t delta;221222delta = *delta_ptr;223224assert(delta >= 0);225226/* The delta size is strictly more than received bytes. Increase227local_window_size by that difference |delta|. */228if (*local_window_size_ptr > NGHTTP2_MAX_WINDOW_SIZE - delta) {229return NGHTTP2_ERR_FLOW_CONTROL;230}231232*local_window_size_ptr += delta;233/* If there is recv_reduction due to earlier window_size234reduction, we have to adjust it too. */235recv_reduction_delta = nghttp2_min(*recv_reduction_ptr, delta);236*recv_reduction_ptr -= recv_reduction_delta;237238*recv_window_size_ptr += recv_reduction_delta;239240/* recv_reduction_delta must be paid from *delta_ptr, since it was241added in window size reduction (see below). */242*delta_ptr -= recv_reduction_delta;243244return 0;245}246247int nghttp2_should_send_window_update(int32_t local_window_size,248int32_t recv_window_size) {249return recv_window_size > 0 && recv_window_size >= local_window_size / 2;250}251252const char *nghttp2_strerror(int error_code) {253switch (error_code) {254case 0:255return "Success";256case NGHTTP2_ERR_INVALID_ARGUMENT:257return "Invalid argument";258case NGHTTP2_ERR_BUFFER_ERROR:259return "Out of buffer space";260case NGHTTP2_ERR_UNSUPPORTED_VERSION:261return "Unsupported SPDY version";262case NGHTTP2_ERR_WOULDBLOCK:263return "Operation would block";264case NGHTTP2_ERR_PROTO:265return "Protocol error";266case NGHTTP2_ERR_INVALID_FRAME:267return "Invalid frame octets";268case NGHTTP2_ERR_EOF:269return "EOF";270case NGHTTP2_ERR_DEFERRED:271return "Data transfer deferred";272case NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE:273return "No more Stream ID available";274case NGHTTP2_ERR_STREAM_CLOSED:275return "Stream was already closed or invalid";276case NGHTTP2_ERR_STREAM_CLOSING:277return "Stream is closing";278case NGHTTP2_ERR_STREAM_SHUT_WR:279return "The transmission is not allowed for this stream";280case NGHTTP2_ERR_INVALID_STREAM_ID:281return "Stream ID is invalid";282case NGHTTP2_ERR_INVALID_STREAM_STATE:283return "Invalid stream state";284case NGHTTP2_ERR_DEFERRED_DATA_EXIST:285return "Another DATA frame has already been deferred";286case NGHTTP2_ERR_START_STREAM_NOT_ALLOWED:287return "request HEADERS is not allowed";288case NGHTTP2_ERR_GOAWAY_ALREADY_SENT:289return "GOAWAY has already been sent";290case NGHTTP2_ERR_INVALID_HEADER_BLOCK:291return "Invalid header block";292case NGHTTP2_ERR_INVALID_STATE:293return "Invalid state";294case NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE:295return "The user callback function failed due to the temporal error";296case NGHTTP2_ERR_FRAME_SIZE_ERROR:297return "The length of the frame is invalid";298case NGHTTP2_ERR_HEADER_COMP:299return "Header compression/decompression error";300case NGHTTP2_ERR_FLOW_CONTROL:301return "Flow control error";302case NGHTTP2_ERR_INSUFF_BUFSIZE:303return "Insufficient buffer size given to function";304case NGHTTP2_ERR_PAUSE:305return "Callback was paused by the application";306case NGHTTP2_ERR_TOO_MANY_INFLIGHT_SETTINGS:307return "Too many inflight SETTINGS";308case NGHTTP2_ERR_PUSH_DISABLED:309return "Server push is disabled by peer";310case NGHTTP2_ERR_DATA_EXIST:311return "DATA or HEADERS frame has already been submitted for the stream";312case NGHTTP2_ERR_SESSION_CLOSING:313return "The current session is closing";314case NGHTTP2_ERR_HTTP_HEADER:315return "Invalid HTTP header field was received";316case NGHTTP2_ERR_HTTP_MESSAGING:317return "Violation in HTTP messaging rule";318case NGHTTP2_ERR_REFUSED_STREAM:319return "Stream was refused";320case NGHTTP2_ERR_INTERNAL:321return "Internal error";322case NGHTTP2_ERR_CANCEL:323return "Cancel";324case NGHTTP2_ERR_SETTINGS_EXPECTED:325return "When a local endpoint expects to receive SETTINGS frame, it "326"receives an other type of frame";327case NGHTTP2_ERR_NOMEM:328return "Out of memory";329case NGHTTP2_ERR_CALLBACK_FAILURE:330return "The user callback function failed";331case NGHTTP2_ERR_BAD_CLIENT_MAGIC:332return "Received bad client magic byte string";333case NGHTTP2_ERR_FLOODED:334return "Flooding was detected in this HTTP/2 session, and it must be "335"closed";336case NGHTTP2_ERR_TOO_MANY_SETTINGS:337return "SETTINGS frame contained more than the maximum allowed entries";338default:339return "Unknown error code";340}341}342343/* Generated by gennmchartbl.py */344static const int VALID_HD_NAME_CHARS[] = {3450 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,3460 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,3470 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */,3480 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */,3490 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */,3500 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */,3510 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */,3520 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */,3530 /* SPC */, 1 /* ! */, 0 /* " */, 1 /* # */,3541 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */,3550 /* ( */, 0 /* ) */, 1 /* * */, 1 /* + */,3560 /* , */, 1 /* - */, 1 /* . */, 0 /* / */,3571 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */,3581 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */,3591 /* 8 */, 1 /* 9 */, 0 /* : */, 0 /* ; */,3600 /* < */, 0 /* = */, 0 /* > */, 0 /* ? */,3610 /* @ */, 0 /* A */, 0 /* B */, 0 /* C */,3620 /* D */, 0 /* E */, 0 /* F */, 0 /* G */,3630 /* H */, 0 /* I */, 0 /* J */, 0 /* K */,3640 /* L */, 0 /* M */, 0 /* N */, 0 /* O */,3650 /* P */, 0 /* Q */, 0 /* R */, 0 /* S */,3660 /* T */, 0 /* U */, 0 /* V */, 0 /* W */,3670 /* X */, 0 /* Y */, 0 /* Z */, 0 /* [ */,3680 /* \ */, 0 /* ] */, 1 /* ^ */, 1 /* _ */,3691 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */,3701 /* d */, 1 /* e */, 1 /* f */, 1 /* g */,3711 /* h */, 1 /* i */, 1 /* j */, 1 /* k */,3721 /* l */, 1 /* m */, 1 /* n */, 1 /* o */,3731 /* p */, 1 /* q */, 1 /* r */, 1 /* s */,3741 /* t */, 1 /* u */, 1 /* v */, 1 /* w */,3751 /* x */, 1 /* y */, 1 /* z */, 0 /* { */,3761 /* | */, 0 /* } */, 1 /* ~ */, 0 /* DEL */,3770 /* 0x80 */, 0 /* 0x81 */, 0 /* 0x82 */, 0 /* 0x83 */,3780 /* 0x84 */, 0 /* 0x85 */, 0 /* 0x86 */, 0 /* 0x87 */,3790 /* 0x88 */, 0 /* 0x89 */, 0 /* 0x8a */, 0 /* 0x8b */,3800 /* 0x8c */, 0 /* 0x8d */, 0 /* 0x8e */, 0 /* 0x8f */,3810 /* 0x90 */, 0 /* 0x91 */, 0 /* 0x92 */, 0 /* 0x93 */,3820 /* 0x94 */, 0 /* 0x95 */, 0 /* 0x96 */, 0 /* 0x97 */,3830 /* 0x98 */, 0 /* 0x99 */, 0 /* 0x9a */, 0 /* 0x9b */,3840 /* 0x9c */, 0 /* 0x9d */, 0 /* 0x9e */, 0 /* 0x9f */,3850 /* 0xa0 */, 0 /* 0xa1 */, 0 /* 0xa2 */, 0 /* 0xa3 */,3860 /* 0xa4 */, 0 /* 0xa5 */, 0 /* 0xa6 */, 0 /* 0xa7 */,3870 /* 0xa8 */, 0 /* 0xa9 */, 0 /* 0xaa */, 0 /* 0xab */,3880 /* 0xac */, 0 /* 0xad */, 0 /* 0xae */, 0 /* 0xaf */,3890 /* 0xb0 */, 0 /* 0xb1 */, 0 /* 0xb2 */, 0 /* 0xb3 */,3900 /* 0xb4 */, 0 /* 0xb5 */, 0 /* 0xb6 */, 0 /* 0xb7 */,3910 /* 0xb8 */, 0 /* 0xb9 */, 0 /* 0xba */, 0 /* 0xbb */,3920 /* 0xbc */, 0 /* 0xbd */, 0 /* 0xbe */, 0 /* 0xbf */,3930 /* 0xc0 */, 0 /* 0xc1 */, 0 /* 0xc2 */, 0 /* 0xc3 */,3940 /* 0xc4 */, 0 /* 0xc5 */, 0 /* 0xc6 */, 0 /* 0xc7 */,3950 /* 0xc8 */, 0 /* 0xc9 */, 0 /* 0xca */, 0 /* 0xcb */,3960 /* 0xcc */, 0 /* 0xcd */, 0 /* 0xce */, 0 /* 0xcf */,3970 /* 0xd0 */, 0 /* 0xd1 */, 0 /* 0xd2 */, 0 /* 0xd3 */,3980 /* 0xd4 */, 0 /* 0xd5 */, 0 /* 0xd6 */, 0 /* 0xd7 */,3990 /* 0xd8 */, 0 /* 0xd9 */, 0 /* 0xda */, 0 /* 0xdb */,4000 /* 0xdc */, 0 /* 0xdd */, 0 /* 0xde */, 0 /* 0xdf */,4010 /* 0xe0 */, 0 /* 0xe1 */, 0 /* 0xe2 */, 0 /* 0xe3 */,4020 /* 0xe4 */, 0 /* 0xe5 */, 0 /* 0xe6 */, 0 /* 0xe7 */,4030 /* 0xe8 */, 0 /* 0xe9 */, 0 /* 0xea */, 0 /* 0xeb */,4040 /* 0xec */, 0 /* 0xed */, 0 /* 0xee */, 0 /* 0xef */,4050 /* 0xf0 */, 0 /* 0xf1 */, 0 /* 0xf2 */, 0 /* 0xf3 */,4060 /* 0xf4 */, 0 /* 0xf5 */, 0 /* 0xf6 */, 0 /* 0xf7 */,4070 /* 0xf8 */, 0 /* 0xf9 */, 0 /* 0xfa */, 0 /* 0xfb */,4080 /* 0xfc */, 0 /* 0xfd */, 0 /* 0xfe */, 0 /* 0xff */409};410411int nghttp2_check_header_name(const uint8_t *name, size_t len) {412const uint8_t *last;413if (len == 0) {414return 0;415}416if (*name == ':') {417if (len == 1) {418return 0;419}420++name;421--len;422}423for (last = name + len; name != last; ++name) {424if (!VALID_HD_NAME_CHARS[*name]) {425return 0;426}427}428return 1;429}430431/* Generated by genvchartbl.py */432static const int VALID_HD_VALUE_CHARS[] = {4330 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,4340 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,4350 /* BS */, 1 /* HT */, 0 /* LF */, 0 /* VT */,4360 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */,4370 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */,4380 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */,4390 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */,4400 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */,4411 /* SPC */, 1 /* ! */, 1 /* " */, 1 /* # */,4421 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */,4431 /* ( */, 1 /* ) */, 1 /* * */, 1 /* + */,4441 /* , */, 1 /* - */, 1 /* . */, 1 /* / */,4451 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */,4461 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */,4471 /* 8 */, 1 /* 9 */, 1 /* : */, 1 /* ; */,4481 /* < */, 1 /* = */, 1 /* > */, 1 /* ? */,4491 /* @ */, 1 /* A */, 1 /* B */, 1 /* C */,4501 /* D */, 1 /* E */, 1 /* F */, 1 /* G */,4511 /* H */, 1 /* I */, 1 /* J */, 1 /* K */,4521 /* L */, 1 /* M */, 1 /* N */, 1 /* O */,4531 /* P */, 1 /* Q */, 1 /* R */, 1 /* S */,4541 /* T */, 1 /* U */, 1 /* V */, 1 /* W */,4551 /* X */, 1 /* Y */, 1 /* Z */, 1 /* [ */,4561 /* \ */, 1 /* ] */, 1 /* ^ */, 1 /* _ */,4571 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */,4581 /* d */, 1 /* e */, 1 /* f */, 1 /* g */,4591 /* h */, 1 /* i */, 1 /* j */, 1 /* k */,4601 /* l */, 1 /* m */, 1 /* n */, 1 /* o */,4611 /* p */, 1 /* q */, 1 /* r */, 1 /* s */,4621 /* t */, 1 /* u */, 1 /* v */, 1 /* w */,4631 /* x */, 1 /* y */, 1 /* z */, 1 /* { */,4641 /* | */, 1 /* } */, 1 /* ~ */, 0 /* DEL */,4651 /* 0x80 */, 1 /* 0x81 */, 1 /* 0x82 */, 1 /* 0x83 */,4661 /* 0x84 */, 1 /* 0x85 */, 1 /* 0x86 */, 1 /* 0x87 */,4671 /* 0x88 */, 1 /* 0x89 */, 1 /* 0x8a */, 1 /* 0x8b */,4681 /* 0x8c */, 1 /* 0x8d */, 1 /* 0x8e */, 1 /* 0x8f */,4691 /* 0x90 */, 1 /* 0x91 */, 1 /* 0x92 */, 1 /* 0x93 */,4701 /* 0x94 */, 1 /* 0x95 */, 1 /* 0x96 */, 1 /* 0x97 */,4711 /* 0x98 */, 1 /* 0x99 */, 1 /* 0x9a */, 1 /* 0x9b */,4721 /* 0x9c */, 1 /* 0x9d */, 1 /* 0x9e */, 1 /* 0x9f */,4731 /* 0xa0 */, 1 /* 0xa1 */, 1 /* 0xa2 */, 1 /* 0xa3 */,4741 /* 0xa4 */, 1 /* 0xa5 */, 1 /* 0xa6 */, 1 /* 0xa7 */,4751 /* 0xa8 */, 1 /* 0xa9 */, 1 /* 0xaa */, 1 /* 0xab */,4761 /* 0xac */, 1 /* 0xad */, 1 /* 0xae */, 1 /* 0xaf */,4771 /* 0xb0 */, 1 /* 0xb1 */, 1 /* 0xb2 */, 1 /* 0xb3 */,4781 /* 0xb4 */, 1 /* 0xb5 */, 1 /* 0xb6 */, 1 /* 0xb7 */,4791 /* 0xb8 */, 1 /* 0xb9 */, 1 /* 0xba */, 1 /* 0xbb */,4801 /* 0xbc */, 1 /* 0xbd */, 1 /* 0xbe */, 1 /* 0xbf */,4811 /* 0xc0 */, 1 /* 0xc1 */, 1 /* 0xc2 */, 1 /* 0xc3 */,4821 /* 0xc4 */, 1 /* 0xc5 */, 1 /* 0xc6 */, 1 /* 0xc7 */,4831 /* 0xc8 */, 1 /* 0xc9 */, 1 /* 0xca */, 1 /* 0xcb */,4841 /* 0xcc */, 1 /* 0xcd */, 1 /* 0xce */, 1 /* 0xcf */,4851 /* 0xd0 */, 1 /* 0xd1 */, 1 /* 0xd2 */, 1 /* 0xd3 */,4861 /* 0xd4 */, 1 /* 0xd5 */, 1 /* 0xd6 */, 1 /* 0xd7 */,4871 /* 0xd8 */, 1 /* 0xd9 */, 1 /* 0xda */, 1 /* 0xdb */,4881 /* 0xdc */, 1 /* 0xdd */, 1 /* 0xde */, 1 /* 0xdf */,4891 /* 0xe0 */, 1 /* 0xe1 */, 1 /* 0xe2 */, 1 /* 0xe3 */,4901 /* 0xe4 */, 1 /* 0xe5 */, 1 /* 0xe6 */, 1 /* 0xe7 */,4911 /* 0xe8 */, 1 /* 0xe9 */, 1 /* 0xea */, 1 /* 0xeb */,4921 /* 0xec */, 1 /* 0xed */, 1 /* 0xee */, 1 /* 0xef */,4931 /* 0xf0 */, 1 /* 0xf1 */, 1 /* 0xf2 */, 1 /* 0xf3 */,4941 /* 0xf4 */, 1 /* 0xf5 */, 1 /* 0xf6 */, 1 /* 0xf7 */,4951 /* 0xf8 */, 1 /* 0xf9 */, 1 /* 0xfa */, 1 /* 0xfb */,4961 /* 0xfc */, 1 /* 0xfd */, 1 /* 0xfe */, 1 /* 0xff */497};498499int nghttp2_check_header_value(const uint8_t *value, size_t len) {500const uint8_t *last;501for (last = value + len; value != last; ++value) {502if (!VALID_HD_VALUE_CHARS[*value]) {503return 0;504}505}506return 1;507}508509int nghttp2_check_header_value_rfc9113(const uint8_t *value, size_t len) {510if (len == 0) {511return 1;512}513514if (*value == ' ' || *value == '\t' || *(value + len - 1) == ' ' ||515*(value + len - 1) == '\t') {516return 0;517}518519return nghttp2_check_header_value(value, len);520}521522/* Generated by genmethodchartbl.py */523static char VALID_METHOD_CHARS[] = {5240 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,5250 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,5260 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */,5270 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */,5280 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */,5290 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */,5300 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */,5310 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */,5320 /* SPC */, 1 /* ! */, 0 /* " */, 1 /* # */,5331 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */,5340 /* ( */, 0 /* ) */, 1 /* * */, 1 /* + */,5350 /* , */, 1 /* - */, 1 /* . */, 0 /* / */,5361 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */,5371 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */,5381 /* 8 */, 1 /* 9 */, 0 /* : */, 0 /* ; */,5390 /* < */, 0 /* = */, 0 /* > */, 0 /* ? */,5400 /* @ */, 1 /* A */, 1 /* B */, 1 /* C */,5411 /* D */, 1 /* E */, 1 /* F */, 1 /* G */,5421 /* H */, 1 /* I */, 1 /* J */, 1 /* K */,5431 /* L */, 1 /* M */, 1 /* N */, 1 /* O */,5441 /* P */, 1 /* Q */, 1 /* R */, 1 /* S */,5451 /* T */, 1 /* U */, 1 /* V */, 1 /* W */,5461 /* X */, 1 /* Y */, 1 /* Z */, 0 /* [ */,5470 /* \ */, 0 /* ] */, 1 /* ^ */, 1 /* _ */,5481 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */,5491 /* d */, 1 /* e */, 1 /* f */, 1 /* g */,5501 /* h */, 1 /* i */, 1 /* j */, 1 /* k */,5511 /* l */, 1 /* m */, 1 /* n */, 1 /* o */,5521 /* p */, 1 /* q */, 1 /* r */, 1 /* s */,5531 /* t */, 1 /* u */, 1 /* v */, 1 /* w */,5541 /* x */, 1 /* y */, 1 /* z */, 0 /* { */,5551 /* | */, 0 /* } */, 1 /* ~ */, 0 /* DEL */,5560 /* 0x80 */, 0 /* 0x81 */, 0 /* 0x82 */, 0 /* 0x83 */,5570 /* 0x84 */, 0 /* 0x85 */, 0 /* 0x86 */, 0 /* 0x87 */,5580 /* 0x88 */, 0 /* 0x89 */, 0 /* 0x8a */, 0 /* 0x8b */,5590 /* 0x8c */, 0 /* 0x8d */, 0 /* 0x8e */, 0 /* 0x8f */,5600 /* 0x90 */, 0 /* 0x91 */, 0 /* 0x92 */, 0 /* 0x93 */,5610 /* 0x94 */, 0 /* 0x95 */, 0 /* 0x96 */, 0 /* 0x97 */,5620 /* 0x98 */, 0 /* 0x99 */, 0 /* 0x9a */, 0 /* 0x9b */,5630 /* 0x9c */, 0 /* 0x9d */, 0 /* 0x9e */, 0 /* 0x9f */,5640 /* 0xa0 */, 0 /* 0xa1 */, 0 /* 0xa2 */, 0 /* 0xa3 */,5650 /* 0xa4 */, 0 /* 0xa5 */, 0 /* 0xa6 */, 0 /* 0xa7 */,5660 /* 0xa8 */, 0 /* 0xa9 */, 0 /* 0xaa */, 0 /* 0xab */,5670 /* 0xac */, 0 /* 0xad */, 0 /* 0xae */, 0 /* 0xaf */,5680 /* 0xb0 */, 0 /* 0xb1 */, 0 /* 0xb2 */, 0 /* 0xb3 */,5690 /* 0xb4 */, 0 /* 0xb5 */, 0 /* 0xb6 */, 0 /* 0xb7 */,5700 /* 0xb8 */, 0 /* 0xb9 */, 0 /* 0xba */, 0 /* 0xbb */,5710 /* 0xbc */, 0 /* 0xbd */, 0 /* 0xbe */, 0 /* 0xbf */,5720 /* 0xc0 */, 0 /* 0xc1 */, 0 /* 0xc2 */, 0 /* 0xc3 */,5730 /* 0xc4 */, 0 /* 0xc5 */, 0 /* 0xc6 */, 0 /* 0xc7 */,5740 /* 0xc8 */, 0 /* 0xc9 */, 0 /* 0xca */, 0 /* 0xcb */,5750 /* 0xcc */, 0 /* 0xcd */, 0 /* 0xce */, 0 /* 0xcf */,5760 /* 0xd0 */, 0 /* 0xd1 */, 0 /* 0xd2 */, 0 /* 0xd3 */,5770 /* 0xd4 */, 0 /* 0xd5 */, 0 /* 0xd6 */, 0 /* 0xd7 */,5780 /* 0xd8 */, 0 /* 0xd9 */, 0 /* 0xda */, 0 /* 0xdb */,5790 /* 0xdc */, 0 /* 0xdd */, 0 /* 0xde */, 0 /* 0xdf */,5800 /* 0xe0 */, 0 /* 0xe1 */, 0 /* 0xe2 */, 0 /* 0xe3 */,5810 /* 0xe4 */, 0 /* 0xe5 */, 0 /* 0xe6 */, 0 /* 0xe7 */,5820 /* 0xe8 */, 0 /* 0xe9 */, 0 /* 0xea */, 0 /* 0xeb */,5830 /* 0xec */, 0 /* 0xed */, 0 /* 0xee */, 0 /* 0xef */,5840 /* 0xf0 */, 0 /* 0xf1 */, 0 /* 0xf2 */, 0 /* 0xf3 */,5850 /* 0xf4 */, 0 /* 0xf5 */, 0 /* 0xf6 */, 0 /* 0xf7 */,5860 /* 0xf8 */, 0 /* 0xf9 */, 0 /* 0xfa */, 0 /* 0xfb */,5870 /* 0xfc */, 0 /* 0xfd */, 0 /* 0xfe */, 0 /* 0xff */588};589590int nghttp2_check_method(const uint8_t *value, size_t len) {591const uint8_t *last;592if (len == 0) {593return 0;594}595for (last = value + len; value != last; ++value) {596if (!VALID_METHOD_CHARS[*value]) {597return 0;598}599}600return 1;601}602603/* Generated by genpathchartbl.py */604static char VALID_PATH_CHARS[] = {6050 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,6060 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,6070 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */,6080 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */,6090 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */,6100 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */,6110 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */,6120 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */,6130 /* SPC */, 1 /* ! */, 1 /* " */, 1 /* # */,6141 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */,6151 /* ( */, 1 /* ) */, 1 /* * */, 1 /* + */,6161 /* , */, 1 /* - */, 1 /* . */, 1 /* / */,6171 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */,6181 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */,6191 /* 8 */, 1 /* 9 */, 1 /* : */, 1 /* ; */,6201 /* < */, 1 /* = */, 1 /* > */, 1 /* ? */,6211 /* @ */, 1 /* A */, 1 /* B */, 1 /* C */,6221 /* D */, 1 /* E */, 1 /* F */, 1 /* G */,6231 /* H */, 1 /* I */, 1 /* J */, 1 /* K */,6241 /* L */, 1 /* M */, 1 /* N */, 1 /* O */,6251 /* P */, 1 /* Q */, 1 /* R */, 1 /* S */,6261 /* T */, 1 /* U */, 1 /* V */, 1 /* W */,6271 /* X */, 1 /* Y */, 1 /* Z */, 1 /* [ */,6281 /* \ */, 1 /* ] */, 1 /* ^ */, 1 /* _ */,6291 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */,6301 /* d */, 1 /* e */, 1 /* f */, 1 /* g */,6311 /* h */, 1 /* i */, 1 /* j */, 1 /* k */,6321 /* l */, 1 /* m */, 1 /* n */, 1 /* o */,6331 /* p */, 1 /* q */, 1 /* r */, 1 /* s */,6341 /* t */, 1 /* u */, 1 /* v */, 1 /* w */,6351 /* x */, 1 /* y */, 1 /* z */, 1 /* { */,6361 /* | */, 1 /* } */, 1 /* ~ */, 0 /* DEL */,6371 /* 0x80 */, 1 /* 0x81 */, 1 /* 0x82 */, 1 /* 0x83 */,6381 /* 0x84 */, 1 /* 0x85 */, 1 /* 0x86 */, 1 /* 0x87 */,6391 /* 0x88 */, 1 /* 0x89 */, 1 /* 0x8a */, 1 /* 0x8b */,6401 /* 0x8c */, 1 /* 0x8d */, 1 /* 0x8e */, 1 /* 0x8f */,6411 /* 0x90 */, 1 /* 0x91 */, 1 /* 0x92 */, 1 /* 0x93 */,6421 /* 0x94 */, 1 /* 0x95 */, 1 /* 0x96 */, 1 /* 0x97 */,6431 /* 0x98 */, 1 /* 0x99 */, 1 /* 0x9a */, 1 /* 0x9b */,6441 /* 0x9c */, 1 /* 0x9d */, 1 /* 0x9e */, 1 /* 0x9f */,6451 /* 0xa0 */, 1 /* 0xa1 */, 1 /* 0xa2 */, 1 /* 0xa3 */,6461 /* 0xa4 */, 1 /* 0xa5 */, 1 /* 0xa6 */, 1 /* 0xa7 */,6471 /* 0xa8 */, 1 /* 0xa9 */, 1 /* 0xaa */, 1 /* 0xab */,6481 /* 0xac */, 1 /* 0xad */, 1 /* 0xae */, 1 /* 0xaf */,6491 /* 0xb0 */, 1 /* 0xb1 */, 1 /* 0xb2 */, 1 /* 0xb3 */,6501 /* 0xb4 */, 1 /* 0xb5 */, 1 /* 0xb6 */, 1 /* 0xb7 */,6511 /* 0xb8 */, 1 /* 0xb9 */, 1 /* 0xba */, 1 /* 0xbb */,6521 /* 0xbc */, 1 /* 0xbd */, 1 /* 0xbe */, 1 /* 0xbf */,6531 /* 0xc0 */, 1 /* 0xc1 */, 1 /* 0xc2 */, 1 /* 0xc3 */,6541 /* 0xc4 */, 1 /* 0xc5 */, 1 /* 0xc6 */, 1 /* 0xc7 */,6551 /* 0xc8 */, 1 /* 0xc9 */, 1 /* 0xca */, 1 /* 0xcb */,6561 /* 0xcc */, 1 /* 0xcd */, 1 /* 0xce */, 1 /* 0xcf */,6571 /* 0xd0 */, 1 /* 0xd1 */, 1 /* 0xd2 */, 1 /* 0xd3 */,6581 /* 0xd4 */, 1 /* 0xd5 */, 1 /* 0xd6 */, 1 /* 0xd7 */,6591 /* 0xd8 */, 1 /* 0xd9 */, 1 /* 0xda */, 1 /* 0xdb */,6601 /* 0xdc */, 1 /* 0xdd */, 1 /* 0xde */, 1 /* 0xdf */,6611 /* 0xe0 */, 1 /* 0xe1 */, 1 /* 0xe2 */, 1 /* 0xe3 */,6621 /* 0xe4 */, 1 /* 0xe5 */, 1 /* 0xe6 */, 1 /* 0xe7 */,6631 /* 0xe8 */, 1 /* 0xe9 */, 1 /* 0xea */, 1 /* 0xeb */,6641 /* 0xec */, 1 /* 0xed */, 1 /* 0xee */, 1 /* 0xef */,6651 /* 0xf0 */, 1 /* 0xf1 */, 1 /* 0xf2 */, 1 /* 0xf3 */,6661 /* 0xf4 */, 1 /* 0xf5 */, 1 /* 0xf6 */, 1 /* 0xf7 */,6671 /* 0xf8 */, 1 /* 0xf9 */, 1 /* 0xfa */, 1 /* 0xfb */,6681 /* 0xfc */, 1 /* 0xfd */, 1 /* 0xfe */, 1 /* 0xff */669};670671int nghttp2_check_path(const uint8_t *value, size_t len) {672const uint8_t *last;673for (last = value + len; value != last; ++value) {674if (!VALID_PATH_CHARS[*value]) {675return 0;676}677}678return 1;679}680681/* Generated by genauthoritychartbl.py */682static char VALID_AUTHORITY_CHARS[] = {6830 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,6840 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,6850 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */,6860 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */,6870 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */,6880 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */,6890 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */,6900 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */,6910 /* SPC */, 1 /* ! */, 0 /* " */, 0 /* # */,6921 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */,6931 /* ( */, 1 /* ) */, 1 /* * */, 1 /* + */,6941 /* , */, 1 /* - */, 1 /* . */, 0 /* / */,6951 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */,6961 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */,6971 /* 8 */, 1 /* 9 */, 1 /* : */, 1 /* ; */,6980 /* < */, 1 /* = */, 0 /* > */, 0 /* ? */,6991 /* @ */, 1 /* A */, 1 /* B */, 1 /* C */,7001 /* D */, 1 /* E */, 1 /* F */, 1 /* G */,7011 /* H */, 1 /* I */, 1 /* J */, 1 /* K */,7021 /* L */, 1 /* M */, 1 /* N */, 1 /* O */,7031 /* P */, 1 /* Q */, 1 /* R */, 1 /* S */,7041 /* T */, 1 /* U */, 1 /* V */, 1 /* W */,7051 /* X */, 1 /* Y */, 1 /* Z */, 1 /* [ */,7060 /* \ */, 1 /* ] */, 0 /* ^ */, 1 /* _ */,7070 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */,7081 /* d */, 1 /* e */, 1 /* f */, 1 /* g */,7091 /* h */, 1 /* i */, 1 /* j */, 1 /* k */,7101 /* l */, 1 /* m */, 1 /* n */, 1 /* o */,7111 /* p */, 1 /* q */, 1 /* r */, 1 /* s */,7121 /* t */, 1 /* u */, 1 /* v */, 1 /* w */,7131 /* x */, 1 /* y */, 1 /* z */, 0 /* { */,7140 /* | */, 0 /* } */, 1 /* ~ */, 0 /* DEL */,7150 /* 0x80 */, 0 /* 0x81 */, 0 /* 0x82 */, 0 /* 0x83 */,7160 /* 0x84 */, 0 /* 0x85 */, 0 /* 0x86 */, 0 /* 0x87 */,7170 /* 0x88 */, 0 /* 0x89 */, 0 /* 0x8a */, 0 /* 0x8b */,7180 /* 0x8c */, 0 /* 0x8d */, 0 /* 0x8e */, 0 /* 0x8f */,7190 /* 0x90 */, 0 /* 0x91 */, 0 /* 0x92 */, 0 /* 0x93 */,7200 /* 0x94 */, 0 /* 0x95 */, 0 /* 0x96 */, 0 /* 0x97 */,7210 /* 0x98 */, 0 /* 0x99 */, 0 /* 0x9a */, 0 /* 0x9b */,7220 /* 0x9c */, 0 /* 0x9d */, 0 /* 0x9e */, 0 /* 0x9f */,7230 /* 0xa0 */, 0 /* 0xa1 */, 0 /* 0xa2 */, 0 /* 0xa3 */,7240 /* 0xa4 */, 0 /* 0xa5 */, 0 /* 0xa6 */, 0 /* 0xa7 */,7250 /* 0xa8 */, 0 /* 0xa9 */, 0 /* 0xaa */, 0 /* 0xab */,7260 /* 0xac */, 0 /* 0xad */, 0 /* 0xae */, 0 /* 0xaf */,7270 /* 0xb0 */, 0 /* 0xb1 */, 0 /* 0xb2 */, 0 /* 0xb3 */,7280 /* 0xb4 */, 0 /* 0xb5 */, 0 /* 0xb6 */, 0 /* 0xb7 */,7290 /* 0xb8 */, 0 /* 0xb9 */, 0 /* 0xba */, 0 /* 0xbb */,7300 /* 0xbc */, 0 /* 0xbd */, 0 /* 0xbe */, 0 /* 0xbf */,7310 /* 0xc0 */, 0 /* 0xc1 */, 0 /* 0xc2 */, 0 /* 0xc3 */,7320 /* 0xc4 */, 0 /* 0xc5 */, 0 /* 0xc6 */, 0 /* 0xc7 */,7330 /* 0xc8 */, 0 /* 0xc9 */, 0 /* 0xca */, 0 /* 0xcb */,7340 /* 0xcc */, 0 /* 0xcd */, 0 /* 0xce */, 0 /* 0xcf */,7350 /* 0xd0 */, 0 /* 0xd1 */, 0 /* 0xd2 */, 0 /* 0xd3 */,7360 /* 0xd4 */, 0 /* 0xd5 */, 0 /* 0xd6 */, 0 /* 0xd7 */,7370 /* 0xd8 */, 0 /* 0xd9 */, 0 /* 0xda */, 0 /* 0xdb */,7380 /* 0xdc */, 0 /* 0xdd */, 0 /* 0xde */, 0 /* 0xdf */,7390 /* 0xe0 */, 0 /* 0xe1 */, 0 /* 0xe2 */, 0 /* 0xe3 */,7400 /* 0xe4 */, 0 /* 0xe5 */, 0 /* 0xe6 */, 0 /* 0xe7 */,7410 /* 0xe8 */, 0 /* 0xe9 */, 0 /* 0xea */, 0 /* 0xeb */,7420 /* 0xec */, 0 /* 0xed */, 0 /* 0xee */, 0 /* 0xef */,7430 /* 0xf0 */, 0 /* 0xf1 */, 0 /* 0xf2 */, 0 /* 0xf3 */,7440 /* 0xf4 */, 0 /* 0xf5 */, 0 /* 0xf6 */, 0 /* 0xf7 */,7450 /* 0xf8 */, 0 /* 0xf9 */, 0 /* 0xfa */, 0 /* 0xfb */,7460 /* 0xfc */, 0 /* 0xfd */, 0 /* 0xfe */, 0 /* 0xff */747};748749int nghttp2_check_authority(const uint8_t *value, size_t len) {750const uint8_t *last;751for (last = value + len; value != last; ++value) {752if (!VALID_AUTHORITY_CHARS[*value]) {753return 0;754}755}756return 1;757}758759uint8_t *nghttp2_cpymem(uint8_t *dest, const void *src, size_t len) {760if (len == 0) {761return dest;762}763764memcpy(dest, src, len);765766return dest + len;767}768769const char *nghttp2_http2_strerror(uint32_t error_code) {770switch (error_code) {771case NGHTTP2_NO_ERROR:772return "NO_ERROR";773case NGHTTP2_PROTOCOL_ERROR:774return "PROTOCOL_ERROR";775case NGHTTP2_INTERNAL_ERROR:776return "INTERNAL_ERROR";777case NGHTTP2_FLOW_CONTROL_ERROR:778return "FLOW_CONTROL_ERROR";779case NGHTTP2_SETTINGS_TIMEOUT:780return "SETTINGS_TIMEOUT";781case NGHTTP2_STREAM_CLOSED:782return "STREAM_CLOSED";783case NGHTTP2_FRAME_SIZE_ERROR:784return "FRAME_SIZE_ERROR";785case NGHTTP2_REFUSED_STREAM:786return "REFUSED_STREAM";787case NGHTTP2_CANCEL:788return "CANCEL";789case NGHTTP2_COMPRESSION_ERROR:790return "COMPRESSION_ERROR";791case NGHTTP2_CONNECT_ERROR:792return "CONNECT_ERROR";793case NGHTTP2_ENHANCE_YOUR_CALM:794return "ENHANCE_YOUR_CALM";795case NGHTTP2_INADEQUATE_SECURITY:796return "INADEQUATE_SECURITY";797case NGHTTP2_HTTP_1_1_REQUIRED:798return "HTTP_1_1_REQUIRED";799default:800return "unknown";801}802}803804805