/
nghttp3.h
2646 lines (2497 loc) Β· 81.5 KB
/
nghttp3.h
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* nghttp3
*
* Copyright (c) 2018 nghttp3 contributors
* Copyright (c) 2017 ngtcp2 contributors
* Copyright (c) 2017 nghttp2 contributors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NGHTTP3_H
#define NGHTTP3_H
/* Define WIN32 when build target is Win32 API (borrowed from
libcurl) */
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
# define WIN32
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#if defined(_MSC_VER) && (_MSC_VER < 1800)
/* MSVC < 2013 does not have inttypes.h because it is not C99
compliant. See compiler macros and version number in
https://sourceforge.net/p/predef/wiki/Compilers/ */
# include <stdint.h>
#else /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
# include <inttypes.h>
#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
#include <sys/types.h>
#include <stdarg.h>
#include <stddef.h>
#include <nghttp3/version.h>
#ifdef NGHTTP3_STATICLIB
# define NGHTTP3_EXTERN
#elif defined(WIN32)
# ifdef BUILDING_NGHTTP3
# define NGHTTP3_EXTERN __declspec(dllexport)
# else /* !BUILDING_NGHTTP3 */
# define NGHTTP3_EXTERN __declspec(dllimport)
# endif /* !BUILDING_NGHTTP3 */
#else /* !defined(WIN32) */
# ifdef BUILDING_NGHTTP3
# define NGHTTP3_EXTERN __attribute__((visibility("default")))
# else /* !BUILDING_NGHTTP3 */
# define NGHTTP3_EXTERN
# endif /* !BUILDING_NGHTTP3 */
#endif /* !defined(WIN32) */
/**
* @typedef
*
* :type:`nghttp3_ssize` is signed counterpart of size_t.
*/
typedef ptrdiff_t nghttp3_ssize;
/**
* @macro
*
* :macro:`NGHTTP3_ALPN_H3` is a serialized form of HTTP/3 ALPN
* protocol identifier this library supports. Notice that the first
* byte is the length of the following protocol identifier.
*/
#define NGHTTP3_ALPN_H3 "\x2h3"
/**
* @macrosection
*
* nghttp3 library error codes
*/
/**
* @macro
*
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` indicates that a passed
* argument is invalid.
*/
#define NGHTTP3_ERR_INVALID_ARGUMENT -101
/**
* @macro
*
* :macro:`NGHTTP3_ERR_NOBUF` indicates that a provided buffer does
* not have enough space to store data.
*/
#define NGHTTP3_ERR_NOBUF -102
/**
* @macro
*
* :macro:`NGHTTP3_ERR_INVALID_STATE` indicates that a requested
* operation is not allowed at the current connection state.
*/
#define NGHTTP3_ERR_INVALID_STATE -103
/**
* @macro
*
* :macro:`NGHTTP3_ERR_WOULDBLOCK` indicates that an operation might
* block.
*/
#define NGHTTP3_ERR_WOULDBLOCK -104
/**
* @macro
*
* :macro:`NGHTTP3_ERR_STREAM_IN_USE` indicates that a stream ID is
* already in use.
*/
#define NGHTTP3_ERR_STREAM_IN_USE -105
/**
* @macro
*
* :macro:`NGHTTP3_ERR_MALFORMED_HTTP_HEADER` indicates that an HTTP
* header field is malformed.
*/
#define NGHTTP3_ERR_MALFORMED_HTTP_HEADER -107
/**
* @macro
*
* :macro:`NGHTTP3_ERR_REMOVE_HTTP_HEADER` indicates that an HTTP
* header field is discarded.
*/
#define NGHTTP3_ERR_REMOVE_HTTP_HEADER -108
/**
* @macro
*
* :macro:`NGHTTP3_ERR_MALFORMED_HTTP_MESSAGING` indicates that HTTP
* messaging is malformed.
*/
#define NGHTTP3_ERR_MALFORMED_HTTP_MESSAGING -109
/**
* @macro
*
* :macro:`NGHTTP3_ERR_QPACK_FATAL` indicates that a fatal error is
* occurred during QPACK processing and it cannot be recoverable.
*/
#define NGHTTP3_ERR_QPACK_FATAL -111
/**
* @macro
*
* :macro:`NGHTTP3_ERR_QPACK_HEADER_TOO_LARGE` indicates that a header
* field is too large to process.
*/
#define NGHTTP3_ERR_QPACK_HEADER_TOO_LARGE -112
/**
* @macro
*
* :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND` indicates that a stream is
* not found.
*/
#define NGHTTP3_ERR_STREAM_NOT_FOUND -114
/**
* @macro
*
* :macro:`NGHTTP3_ERR_CONN_CLOSING` indicates that a connection is
* closing state.
*/
#define NGHTTP3_ERR_CONN_CLOSING -116
/**
* @macro
*
* :macro:`NGHTTP3_ERR_STREAM_DATA_OVERFLOW` indicates that the length
* of stream data is too long and causes overflow.
*/
#define NGHTTP3_ERR_STREAM_DATA_OVERFLOW -117
/**
* @macro
*
* :macro:`NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED` indicates that a
* QPACK decompression failed.
*/
#define NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED -402
/**
* @macro
*
* :macro:`NGHTTP3_ERR_QPACK_ENCODER_STREAM_ERROR` indicates that an
* error occurred while reading QPACK encoder stream.
*/
#define NGHTTP3_ERR_QPACK_ENCODER_STREAM_ERROR -403
/**
* @macro
*
* :macro:`NGHTTP3_ERR_QPACK_DECODER_STREAM_ERROR` indicates that an
* error occurred while reading QPACK decoder stream.
*/
#define NGHTTP3_ERR_QPACK_DECODER_STREAM_ERROR -404
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_FRAME_UNEXPECTED` indicates that an
* unexpected HTTP/3 frame is received.
*/
#define NGHTTP3_ERR_H3_FRAME_UNEXPECTED -408
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_FRAME_ERROR` indicates that an HTTP/3 frame
* is malformed.
*/
#define NGHTTP3_ERR_H3_FRAME_ERROR -409
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_MISSING_SETTINGS` indicates that an HTTP/3
* SETTINGS frame is missing.
*/
#define NGHTTP3_ERR_H3_MISSING_SETTINGS -665
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_INTERNAL_ERROR` indicates an internal error.
*/
#define NGHTTP3_ERR_H3_INTERNAL_ERROR -667
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM` indicates that a
* critical stream is closed.
*/
#define NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM -668
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_GENERAL_PROTOCOL_ERROR` indicates a general
* protocol error. This is typically a catch-all error.
*/
#define NGHTTP3_ERR_H3_GENERAL_PROTOCOL_ERROR -669
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_ID_ERROR` indicates that an ID related error
* occurred.
*/
#define NGHTTP3_ERR_H3_ID_ERROR -670
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_SETTINGS_ERROR` indicates that an HTTP/3
* SETTINGS frame is malformed.
*/
#define NGHTTP3_ERR_H3_SETTINGS_ERROR -671
/**
* @macro
*
* :macro:`NGHTTP3_ERR_H3_STREAM_CREATION_ERROR` indicates that a
* remote endpoint attempts to create a new stream which is not
* allowed.
*/
#define NGHTTP3_ERR_H3_STREAM_CREATION_ERROR -672
/**
* @macro
*
* :macro:`NGHTTP3_ERR_FATAL` indicates that error codes less than
* this value is fatal error. When this error is returned, an
* endpoint should drop connection immediately.
*/
#define NGHTTP3_ERR_FATAL -900
/**
* @macro
*
* :macro:`NGHTTP3_ERR_NOMEM` indicates out of memory.
*/
#define NGHTTP3_ERR_NOMEM -901
/**
* @macro
*
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` indicates that user defined
* callback function failed.
*/
#define NGHTTP3_ERR_CALLBACK_FAILURE -902
/**
* @macrosection
*
* HTTP/3 application error code
*/
/**
* @macro
*
* :macro:`NGHTTP3_H3_NO_ERROR` is HTTP/3 application error code
* ``H3_NO_ERROR``.
*/
#define NGHTTP3_H3_NO_ERROR 0x0100
/**
* @macro
*
* :macro:`NGHTTP3_H3_GENERAL_PROTOCOL_ERROR` is HTTP/3 application
* error code ``H3_GENERAL_PROTOCOL_ERROR``.
*/
#define NGHTTP3_H3_GENERAL_PROTOCOL_ERROR 0x0101
/**
* @macro
*
* :macro:`NGHTTP3_H3_INTERNAL_ERROR` is HTTP/3 application error code
* ``H3_INTERNAL_ERROR``.
*/
#define NGHTTP3_H3_INTERNAL_ERROR 0x0102
/**
* @macro
*
* :macro:`NGHTTP3_H3_STREAM_CREATION_ERROR` is HTTP/3 application
* error code ``H3_STREAM_CREATION_ERROR``.
*/
#define NGHTTP3_H3_STREAM_CREATION_ERROR 0x0103
/**
* @macro
*
* :macro:`NGHTTP3_H3_CLOSED_CRITICAL_STREAM` is HTTP/3 application
* error code ``H3_CLOSED_CRITICAL_STREAM``.
*/
#define NGHTTP3_H3_CLOSED_CRITICAL_STREAM 0x0104
/**
* @macro
*
* :macro:`NGHTTP3_H3_FRAME_UNEXPECTED` is HTTP/3 application error
* code ``H3_FRAME_UNEXPECTED``.
*/
#define NGHTTP3_H3_FRAME_UNEXPECTED 0x0105
/**
* @macro
*
* :macro:`NGHTTP3_H3_FRAME_ERROR` is HTTP/3 application error code
* ``H3_FRAME_ERROR``.
*/
#define NGHTTP3_H3_FRAME_ERROR 0x0106
/**
* @macro
*
* :macro:`NGHTTP3_H3_EXCESSIVE_LOAD` is HTTP/3 application error code
* ``H3_EXCESSIVE_LOAD``.
*/
#define NGHTTP3_H3_EXCESSIVE_LOAD 0x0107
/**
* @macro
*
* :macro:`NGHTTP3_H3_ID_ERROR` is HTTP/3 application error code
* ``H3_ID_ERROR``.
*/
#define NGHTTP3_H3_ID_ERROR 0x0108
/**
* @macro
*
* :macro:`NGHTTP3_H3_SETTINGS_ERROR` is HTTP/3 application error code
* ``H3_SETTINGS_ERROR``.
*/
#define NGHTTP3_H3_SETTINGS_ERROR 0x0109
/**
* @macro
*
* :macro:`NGHTTP3_H3_MISSING_SETTINGS` is HTTP/3 application error
* code ``H3_MISSING_SETTINGS``.
*/
#define NGHTTP3_H3_MISSING_SETTINGS 0x010a
/**
* @macro
*
* :macro:`NGHTTP3_H3_REQUEST_REJECTED` is HTTP/3 application error
* code ``H3_REQUEST_REJECTED``.
*/
#define NGHTTP3_H3_REQUEST_REJECTED 0x010b
/**
* @macro
*
* :macro:`NGHTTP3_H3_REQUEST_CANCELLED` is HTTP/3 application error
* code ``H3_REQUEST_CANCELLED``.
*/
#define NGHTTP3_H3_REQUEST_CANCELLED 0x010c
/**
* @macro
*
* :macro:`NGHTTP3_H3_REQUEST_INCOMPLETE` is HTTP/3 application error
* code ``H3_REQUEST_INCOMPLETE``.
*/
#define NGHTTP3_H3_REQUEST_INCOMPLETE 0x010d
/**
* @macro
*
* :macro:`NGHTTP3_H3_MESSAGE_ERROR` is HTTP/3 application error code
* ``H3_MESSAGE_ERROR``.
*/
#define NGHTTP3_H3_MESSAGE_ERROR 0x010e
/**
* @macro
*
* :macro:`NGHTTP3_H3_CONNECT_ERROR` is HTTP/3 application error code
* ``H3_CONNECT_ERROR``.
*/
#define NGHTTP3_H3_CONNECT_ERROR 0x010f
/**
* @macro
*
* :macro:`NGHTTP3_H3_VERSION_FALLBACK` is HTTP/3 application error
* code ``H3_VERSION_FALLBACK``.
*/
#define NGHTTP3_H3_VERSION_FALLBACK 0x0110
/**
* @macro
*
* :macro:`NGHTTP3_QPACK_DECOMPRESSION_FAILED` is HTTP/3 application
* error code ``QPACK_DECOMPRESSION_FAILED``.
*/
#define NGHTTP3_QPACK_DECOMPRESSION_FAILED 0x0200
/**
* @macro
*
* :macro:`NGHTTP3_QPACK_ENCODER_STREAM_ERROR` is HTTP/3 application
* error code ``QPACK_ENCODER_STREAM_ERROR``.
*/
#define NGHTTP3_QPACK_ENCODER_STREAM_ERROR 0x0201
/**
* @macro
*
* :macro:`NGHTTP3_QPACK_DECODER_STREAM_ERROR` is HTTP/3 application
* error code ``QPACK_DECODER_STREAM_ERROR``.
*/
#define NGHTTP3_QPACK_DECODER_STREAM_ERROR 0x0202
/**
* @functypedef
*
* :type:`nghttp3_malloc` is a custom memory allocator to replace
* :manpage:`malloc(3)`. The |user_data| is the
* :member:`nghttp3_mem.user_data`.
*/
typedef void *(*nghttp3_malloc)(size_t size, void *user_data);
/**
* @functypedef
*
* :type:`nghttp3_free` is a custom memory allocator to replace
* :manpage:`free(3)`. The |user_data| is the
* :member:`nghttp3_mem.user_data`.
*/
typedef void (*nghttp3_free)(void *ptr, void *user_data);
/**
* @functypedef
*
* :type:`nghttp3_calloc` is a custom memory allocator to replace
* :manpage:`calloc(3)`. The |user_data| is the
* :member:`nghttp3_mem.user_data`.
*/
typedef void *(*nghttp3_calloc)(size_t nmemb, size_t size, void *user_data);
/**
* @functypedef
*
* :type:`nghttp3_realloc` is a custom memory allocator to replace
* :manpage:`realloc(3)`. The |user_data| is the
* :member:`nghttp3_mem.user_data`.
*/
typedef void *(*nghttp3_realloc)(void *ptr, size_t size, void *user_data);
/**
* @struct
*
* :type:`nghttp3_mem` is a custom memory allocator functions and user
* defined pointer. The :member:`user_data` field is passed to each
* allocator function. This can be used, for example, to achieve
* per-session memory pool.
*
* In the following example code, ``my_malloc``, ``my_free``,
* ``my_calloc`` and ``my_realloc`` are the replacement of the
* standard allocators :manpage:`malloc(3)`, :manpage:`free(3)`,
* :manpage:`calloc(3)` and :manpage:`realloc(3)` respectively::
*
* void *my_malloc_cb(size_t size, void *user_data) {
* (void)user_data;
* return my_malloc(size);
* }
*
* void my_free_cb(void *ptr, void *user_data) {
* (void)user_data;
* my_free(ptr);
* }
*
* void *my_calloc_cb(size_t nmemb, size_t size, void *user_data) {
* (void)user_data;
* return my_calloc(nmemb, size);
* }
*
* void *my_realloc_cb(void *ptr, size_t size, void *user_data) {
* (void)user_data;
* return my_realloc(ptr, size);
* }
*
* void conn_new() {
* nghttp3_mem mem = {NULL, my_malloc_cb, my_free_cb, my_calloc_cb,
* my_realloc_cb};
*
* ...
* }
*/
typedef struct nghttp3_mem {
/**
* :member:`user_data` is an arbitrary user supplied data. This
* is passed to each allocator function.
*/
void *user_data;
/**
* :member:`malloc` is a custom allocator function to replace
* :manpage:`malloc(3)`.
*/
nghttp3_malloc malloc;
/**
* :member:`free` is a custom allocator function to replace
* :manpage:`free(3)`.
*/
nghttp3_free free;
/**
* :member:`calloc` is a custom allocator function to replace
* :manpage:`calloc(3)`.
*/
nghttp3_calloc calloc;
/**
* :member:`realloc` is a custom allocator function to replace
* :manpage:`realloc(3)`.
*/
nghttp3_realloc realloc;
} nghttp3_mem;
/**
* @function
*
* `nghttp3_mem_default` returns the default memory allocator which
* uses malloc/calloc/realloc/free.
*/
NGHTTP3_EXTERN const nghttp3_mem *nghttp3_mem_default(void);
/**
* @struct
*
* :type:`nghttp3_vec` is ``struct iovec`` compatible structure to
* reference arbitrary array of bytes.
*/
typedef struct nghttp3_vec {
/**
* :member:`base` points to the data.
*/
uint8_t *base;
/**
* :member:`len` is the number of bytes which the buffer pointed by
* base contains.
*/
size_t len;
} nghttp3_vec;
/**
* @struct
*
* :type:`nghttp3_rcbuf` is the object representing reference counted
* buffer. The details of this structure are intentionally hidden
* from the public API.
*/
typedef struct nghttp3_rcbuf nghttp3_rcbuf;
/**
* @function
*
* `nghttp3_rcbuf_incref` increments the reference count of |rcbuf| by
* 1.
*/
NGHTTP3_EXTERN void nghttp3_rcbuf_incref(nghttp3_rcbuf *rcbuf);
/**
* @function
*
* `nghttp3_rcbuf_decref` decrements the reference count of |rcbuf| by
* 1. If the reference count becomes zero, the object pointed by
* |rcbuf| will be freed. In this case, application must not use
* |rcbuf| again.
*/
NGHTTP3_EXTERN void nghttp3_rcbuf_decref(nghttp3_rcbuf *rcbuf);
/**
* @function
*
* `nghttp3_rcbuf_get_buf` returns the underlying buffer managed by
* |rcbuf|.
*/
NGHTTP3_EXTERN nghttp3_vec nghttp3_rcbuf_get_buf(const nghttp3_rcbuf *rcbuf);
/**
* @function
*
* `nghttp3_rcbuf_is_static` returns nonzero if the underlying buffer
* is statically allocated, and 0 otherwise. This can be useful for
* language bindings that wish to avoid creating duplicate strings for
* these buffers.
*/
NGHTTP3_EXTERN int nghttp3_rcbuf_is_static(const nghttp3_rcbuf *rcbuf);
/**
* @struct
*
* :type:`nghttp3_buf` is the variable size buffer.
*/
typedef struct nghttp3_buf {
/**
* :member:`begin` points to the beginning of the buffer.
*/
uint8_t *begin;
/**
* :member:`end` points to the one beyond of the last byte of the
* buffer
*/
uint8_t *end;
/**
* :member:`pos` pointers to the start of data. Typically, this
* points to the point that next data should be read. Initially, it
* points to :member:`begin`.
*/
uint8_t *pos;
/**
* :member:`last` points to the one beyond of the last data of the
* buffer. Typically, new data is written at this point.
* Initially, it points to :member:`begin`.
*/
uint8_t *last;
} nghttp3_buf;
/**
* @function
*
* `nghttp3_buf_init` initializes empty |buf|.
*/
NGHTTP3_EXTERN void nghttp3_buf_init(nghttp3_buf *buf);
/**
* @function
*
* `nghttp3_buf_free` frees resources allocated for |buf| using |mem|
* as memory allocator. :member:`buf->begin <nghttp3_buf.begin>` must
* be a heap buffer allocated by |mem|.
*/
NGHTTP3_EXTERN void nghttp3_buf_free(nghttp3_buf *buf, const nghttp3_mem *mem);
/**
* @function
*
* `nghttp3_buf_left` returns the number of additional bytes which can
* be written to the underlying buffer. In other words, it returns
* :member:`buf->end <nghttp3_buf.end>` - :member:`buf->last
* <nghttp3_buf.last>`.
*/
NGHTTP3_EXTERN size_t nghttp3_buf_left(const nghttp3_buf *buf);
/**
* @function
*
* `nghttp3_buf_len` returns the number of bytes left to read. In
* other words, it returns :member:`buf->last <nghttp3_buf.last>` -
* :member:`buf->pos <nghttp3_buf.pos>`.
*/
NGHTTP3_EXTERN size_t nghttp3_buf_len(const nghttp3_buf *buf);
/**
* @function
*
* `nghttp3_buf_reset` sets :member:`buf->pos <nghttp3_buf.pos>` and
* :member:`buf->last <nghttp3_buf.last>` to :member:`buf->begin
* <nghttp3_buf.begin>`.
*/
NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf);
/**
* @macrosection
*
* Flags for header field name/value pair
*/
/**
* @macro
*
* :macro:`NGHTTP3_NV_FLAG_NONE` indicates no flag set.
*/
#define NGHTTP3_NV_FLAG_NONE 0x00u
/**
* @macro
*
* :macro:`NGHTTP3_NV_FLAG_NEVER_INDEX` indicates that this name/value
* pair must not be indexed. Other implementation calls this bit as
* "sensitive".
*/
#define NGHTTP3_NV_FLAG_NEVER_INDEX 0x01u
/**
* @macro
*
* :macro:`NGHTTP3_NV_FLAG_NO_COPY_NAME` is set solely by application.
* If this flag is set, the library does not make a copy of header
* field name. This could improve performance.
*/
#define NGHTTP3_NV_FLAG_NO_COPY_NAME 0x02u
/**
* @macro
*
* :macro:`NGHTTP3_NV_FLAG_NO_COPY_VALUE` is set solely by
* application. If this flag is set, the library does not make a copy
* of header field value. This could improve performance.
*/
#define NGHTTP3_NV_FLAG_NO_COPY_VALUE 0x04u
/**
* @struct
*
* :type:`nghttp3_nv` is the name/value pair, which mainly used to
* represent header fields.
*/
typedef struct nghttp3_nv {
/**
* :member:`name` is the header field name.
*/
uint8_t *name;
/**
* :member:`value` is the header field value.
*/
uint8_t *value;
/**
* :member:`namelen` is the length of the |name|, excluding
* terminating NULL.
*/
size_t namelen;
/**
* :member:`valuelen` is the length of the |value|, excluding
* terminating NULL.
*/
size_t valuelen;
/**
* :member:`flags` is bitwise OR of one or more of
* :macro:`NGHTTP3_NV_FLAG_* <NGHTTP3_NV_FLAG_NONE>`.
*/
uint8_t flags;
} nghttp3_nv;
/* Generated by mkstatichdtbl.py */
/**
* @enum
*
* :type:`nghttp3_qpack_token` defines HTTP header field name tokens
* to identify field name quickly. It appears in
* :member:`nghttp3_qpack_nv.token`.
*/
typedef enum nghttp3_qpack_token {
/**
* :enum:`NGHTTP3_QPACK_TOKEN__AUTHORITY` is a token for
* ``:authority``.
*/
NGHTTP3_QPACK_TOKEN__AUTHORITY = 0,
/**
* :enum:`NGHTTP3_QPACK_TOKEN__PATH` is a token for ``:path``.
*/
NGHTTP3_QPACK_TOKEN__PATH = 8,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_AGE` is a token for ``age``.
*/
NGHTTP3_QPACK_TOKEN_AGE = 43,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_DISPOSITION` is a token for
* ``content-disposition``.
*/
NGHTTP3_QPACK_TOKEN_CONTENT_DISPOSITION = 52,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_LENGTH` is a token for
* ``content-length``.
*/
NGHTTP3_QPACK_TOKEN_CONTENT_LENGTH = 55,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_COOKIE` is a token for ``cookie``.
*/
NGHTTP3_QPACK_TOKEN_COOKIE = 68,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_DATE` is a token for ``date``.
*/
NGHTTP3_QPACK_TOKEN_DATE = 69,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ETAG` is a token for ``etag``.
*/
NGHTTP3_QPACK_TOKEN_ETAG = 71,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_IF_MODIFIED_SINCE` is a token for
* ``if-modified-since``.
*/
NGHTTP3_QPACK_TOKEN_IF_MODIFIED_SINCE = 74,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_IF_NONE_MATCH` is a token for
* ``if-none-match``.
*/
NGHTTP3_QPACK_TOKEN_IF_NONE_MATCH = 75,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_LAST_MODIFIED` is a token for
* ``last-modified``.
*/
NGHTTP3_QPACK_TOKEN_LAST_MODIFIED = 77,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_LINK` is a token for ``link``.
*/
NGHTTP3_QPACK_TOKEN_LINK = 78,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_LOCATION` is a token for ``location``.
*/
NGHTTP3_QPACK_TOKEN_LOCATION = 79,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_REFERER` is a token for ``referer``.
*/
NGHTTP3_QPACK_TOKEN_REFERER = 83,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_SET_COOKIE` is a token for
* ``set-cookie``.
*/
NGHTTP3_QPACK_TOKEN_SET_COOKIE = 85,
/**
* :enum:`NGHTTP3_QPACK_TOKEN__METHOD` is a token for ``:method``.
*/
NGHTTP3_QPACK_TOKEN__METHOD = 1,
/**
* :enum:`NGHTTP3_QPACK_TOKEN__SCHEME` is a token for ``:scheme``.
*/
NGHTTP3_QPACK_TOKEN__SCHEME = 9,
/**
* :enum:`NGHTTP3_QPACK_TOKEN__STATUS` is a token for ``:status``.
*/
NGHTTP3_QPACK_TOKEN__STATUS = 11,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT` is a token for ``accept``.
*/
NGHTTP3_QPACK_TOKEN_ACCEPT = 25,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT_ENCODING` is a token for
* ``accept-encoding``.
*/
NGHTTP3_QPACK_TOKEN_ACCEPT_ENCODING = 27,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT_RANGES` is a token for
* ``accept-ranges``.
*/
NGHTTP3_QPACK_TOKEN_ACCEPT_RANGES = 29,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS` is a
* token for ``access-control-allow-headers``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS = 32,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_ORIGIN` is a
* token for ``access-control-allow-origin``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_ORIGIN = 38,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_CACHE_CONTROL` is a token for
* ``cache-control``.
*/
NGHTTP3_QPACK_TOKEN_CACHE_CONTROL = 46,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING` is a token for
* ``content-encoding``.
*/
NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING = 53,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_TYPE` is a token for
* ``content-type``.
*/
NGHTTP3_QPACK_TOKEN_CONTENT_TYPE = 57,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_RANGE` is a token for ``range``.
*/
NGHTTP3_QPACK_TOKEN_RANGE = 82,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY` is a token
* for ``strict-transport-security``.
*/
NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY = 86,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_VARY` is a token for ``vary``.
*/
NGHTTP3_QPACK_TOKEN_VARY = 92,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_X_CONTENT_TYPE_OPTIONS` is a token for
* ``x-content-type-options``.
*/
NGHTTP3_QPACK_TOKEN_X_CONTENT_TYPE_OPTIONS = 94,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_X_XSS_PROTECTION` is a token for
* ``x-xss-protection``.
*/
NGHTTP3_QPACK_TOKEN_X_XSS_PROTECTION = 98,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT_LANGUAGE` is a token for
* ``accept-language``.
*/
NGHTTP3_QPACK_TOKEN_ACCEPT_LANGUAGE = 28,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_CREDENTIALS` is a
* token for ``access-control-allow-credentials``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_CREDENTIALS = 30,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS` is a
* token for ``access-control-allow-methods``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS = 35,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_EXPOSE_HEADERS` is a
* token for ``access-control-expose-headers``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_EXPOSE_HEADERS = 39,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_HEADERS` is a
* token for ``access-control-request-headers``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_HEADERS = 40,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_METHOD` is a
* token for ``access-control-request-method``.
*/
NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_METHOD = 41,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ALT_SVC` is a token for ``alt-svc``.
*/
NGHTTP3_QPACK_TOKEN_ALT_SVC = 44,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_AUTHORIZATION` is a token for
* ``authorization``.
*/
NGHTTP3_QPACK_TOKEN_AUTHORIZATION = 45,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_SECURITY_POLICY` is a token
* for ``content-security-policy``.
*/
NGHTTP3_QPACK_TOKEN_CONTENT_SECURITY_POLICY = 56,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_EARLY_DATA` is a token for
* ``early-data``.
*/
NGHTTP3_QPACK_TOKEN_EARLY_DATA = 70,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_EXPECT_CT` is a token for
* ``expect-ct``.
*/
NGHTTP3_QPACK_TOKEN_EXPECT_CT = 72,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_FORWARDED` is a token for
* ``forwarded``.
*/
NGHTTP3_QPACK_TOKEN_FORWARDED = 73,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_IF_RANGE` is a token for ``if-range``.
*/
NGHTTP3_QPACK_TOKEN_IF_RANGE = 76,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_ORIGIN` is a token for ``origin``.
*/
NGHTTP3_QPACK_TOKEN_ORIGIN = 80,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_PURPOSE` is a token for ``purpose``.
*/
NGHTTP3_QPACK_TOKEN_PURPOSE = 81,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_SERVER` is a token for ``server``.
*/
NGHTTP3_QPACK_TOKEN_SERVER = 84,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_TIMING_ALLOW_ORIGIN` is a token for
* ``timing-allow-origin``.
*/
NGHTTP3_QPACK_TOKEN_TIMING_ALLOW_ORIGIN = 89,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_UPGRADE_INSECURE_REQUESTS` is a token
* for ``upgrade-insecure-requests``.
*/
NGHTTP3_QPACK_TOKEN_UPGRADE_INSECURE_REQUESTS = 90,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_USER_AGENT` is a token for
* ``user-agent``.
*/
NGHTTP3_QPACK_TOKEN_USER_AGENT = 91,
/**
* :enum:`NGHTTP3_QPACK_TOKEN_X_FORWARDED_FOR` is a token for
* ``x-forwarded-for``.
*/