28
28
/* Define WIN32 when build target is Win32 API (borrowed from
29
29
libcurl) */
30
30
#if (defined(_WIN32 ) || defined(__WIN32__ )) && !defined(WIN32 )
31
- #define WIN32
31
+ # define WIN32
32
32
#endif
33
33
34
34
#ifdef __cplusplus
@@ -40,30 +40,30 @@ extern "C" {
40
40
/* MSVC < 2013 does not have inttypes.h because it is not C99
41
41
compliant. See compiler macros and version number in
42
42
https://sourceforge.net/p/predef/wiki/Compilers/ */
43
- #include <stdint.h>
43
+ # include <stdint.h>
44
44
#else /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
45
- #include <inttypes.h>
45
+ # include <inttypes.h>
46
46
#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
47
47
#include <sys/types.h>
48
48
#include <stdarg.h>
49
49
50
50
#include <nghttp2/nghttp2ver.h>
51
51
52
52
#ifdef NGHTTP2_STATICLIB
53
- #define NGHTTP2_EXTERN
53
+ # define NGHTTP2_EXTERN
54
54
#elif defined(WIN32 )
55
- #ifdef BUILDING_NGHTTP2
56
- #define NGHTTP2_EXTERN __declspec(dllexport)
57
- #else /* !BUILDING_NGHTTP2 */
58
- #define NGHTTP2_EXTERN __declspec(dllimport)
59
- #endif /* !BUILDING_NGHTTP2 */
60
- #else /* !defined(WIN32) */
61
- #ifdef BUILDING_NGHTTP2
62
- #define NGHTTP2_EXTERN __attribute__((visibility("default")))
63
- #else /* !BUILDING_NGHTTP2 */
64
- #define NGHTTP2_EXTERN
65
- #endif /* !BUILDING_NGHTTP2 */
66
- #endif /* !defined(WIN32) */
55
+ # ifdef BUILDING_NGHTTP2
56
+ # define NGHTTP2_EXTERN __declspec(dllexport)
57
+ # else /* !BUILDING_NGHTTP2 */
58
+ # define NGHTTP2_EXTERN __declspec(dllimport)
59
+ # endif /* !BUILDING_NGHTTP2 */
60
+ #else /* !defined(WIN32) */
61
+ # ifdef BUILDING_NGHTTP2
62
+ # define NGHTTP2_EXTERN __attribute__((visibility("default")))
63
+ # else /* !BUILDING_NGHTTP2 */
64
+ # define NGHTTP2_EXTERN
65
+ # endif /* !BUILDING_NGHTTP2 */
66
+ #endif /* !defined(WIN32) */
67
67
68
68
/**
69
69
* @macro
@@ -611,7 +611,12 @@ typedef enum {
611
611
* The ALTSVC frame, which is defined in `RFC 7383
612
612
* <https://tools.ietf.org/html/rfc7838#section-4>`_.
613
613
*/
614
- NGHTTP2_ALTSVC = 0x0a
614
+ NGHTTP2_ALTSVC = 0x0a ,
615
+ /**
616
+ * The ORIGIN frame, which is defined by `RFC 8336
617
+ * <https://tools.ietf.org/html/rfc8336>`_.
618
+ */
619
+ NGHTTP2_ORIGIN = 0x0c
615
620
} nghttp2_frame_type ;
616
621
617
622
/**
@@ -2473,15 +2478,15 @@ nghttp2_option_set_no_auto_window_update(nghttp2_option *option, int val);
2473
2478
*
2474
2479
* This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
2475
2480
* remote endpoint as if it is received in SETTINGS frame. Without
2476
- * specifying this option, before the local endpoint receives
2477
- * SETTINGS_MAX_CONCURRENT_STREAMS in SETTINGS frame from remote
2478
- * endpoint, SETTINGS_MAX_CONCURRENT_STREAMS is unlimited. This may
2479
- * cause problem if local endpoint submits lots of requests initially
2480
- * and sending them at once to the remote peer may lead to the
2481
- * rejection of some requests. Specifying this option to the sensible
2482
- * value, say 100, may avoid this kind of issue. This value will be
2483
- * overwritten if the local endpoint receives
2484
- * SETTINGS_MAX_CONCURRENT_STREAMS from the remote endpoint .
2481
+ * specifying this option, the maximum number of outgoing concurrent
2482
+ * streams is initially limited to 100 to avoid issues when the local
2483
+ * endpoint submits lots of requests before receiving initial SETTINGS
2484
+ * frame from the remote endpoint, since sending them at once to the
2485
+ * remote endpoint could lead to rejection of some of the requests.
2486
+ * This value will be overwritten when the local endpoint receives
2487
+ * initial SETTINGS frame from the remote endpoint, either to the
2488
+ * value advertised in SETTINGS_MAX_CONCURRENT_STREAMS or to the
2489
+ * default value (unlimited) if none was advertised .
2485
2490
*/
2486
2491
NGHTTP2_EXTERN void
2487
2492
nghttp2_option_set_peer_max_concurrent_streams (nghttp2_option * option ,
@@ -3797,10 +3802,13 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
3797
3802
* .. warning::
3798
3803
*
3799
3804
* This function returns assigned stream ID if it succeeds. But
3800
- * that stream is not opened yet. The application must not submit
3805
+ * that stream is not created yet. The application must not submit
3801
3806
* frame to that stream ID before
3802
3807
* :type:`nghttp2_before_frame_send_callback` is called for this
3803
- * frame.
3808
+ * frame. This means `nghttp2_session_get_stream_user_data()` does
3809
+ * not work before the callback. But
3810
+ * `nghttp2_session_set_stream_user_data()` handles this situation
3811
+ * specially, and it can set data to a stream during this period.
3804
3812
*
3805
3813
*/
3806
3814
NGHTTP2_EXTERN int32_t nghttp2_submit_request (
@@ -4516,8 +4524,7 @@ typedef struct {
4516
4524
* Submits ALTSVC frame.
4517
4525
*
4518
4526
* ALTSVC frame is a non-critical extension to HTTP/2, and defined in
4519
- * is defined in `RFC 7383
4520
- * <https://tools.ietf.org/html/rfc7838#section-4>`_.
4527
+ * `RFC 7383 <https://tools.ietf.org/html/rfc7838#section-4>`_.
4521
4528
*
4522
4529
* The |flags| is currently ignored and should be
4523
4530
* :enum:`NGHTTP2_FLAG_NONE`.
@@ -4551,6 +4558,81 @@ NGHTTP2_EXTERN int nghttp2_submit_altsvc(nghttp2_session *session,
4551
4558
const uint8_t * field_value ,
4552
4559
size_t field_value_len );
4553
4560
4561
+ /**
4562
+ * @struct
4563
+ *
4564
+ * The single entry of an origin.
4565
+ */
4566
+ typedef struct {
4567
+ /**
4568
+ * The pointer to origin. No validation is made against this field
4569
+ * by the library. This is not necessarily NULL-terminated.
4570
+ */
4571
+ uint8_t * origin ;
4572
+ /**
4573
+ * The length of the |origin|.
4574
+ */
4575
+ size_t origin_len ;
4576
+ } nghttp2_origin_entry ;
4577
+
4578
+ /**
4579
+ * @struct
4580
+ *
4581
+ * The payload of ORIGIN frame. ORIGIN frame is a non-critical
4582
+ * extension to HTTP/2 and defined by `RFC 8336
4583
+ * <https://tools.ietf.org/html/rfc8336>`_.
4584
+ *
4585
+ * If this frame is received, and
4586
+ * `nghttp2_option_set_user_recv_extension_type()` is not set, and
4587
+ * `nghttp2_option_set_builtin_recv_extension_type()` is set for
4588
+ * :enum:`NGHTTP2_ORIGIN`, ``nghttp2_extension.payload`` will point to
4589
+ * this struct.
4590
+ *
4591
+ * It has the following members:
4592
+ */
4593
+ typedef struct {
4594
+ /**
4595
+ * The number of origins contained in |ov|.
4596
+ */
4597
+ size_t nov ;
4598
+ /**
4599
+ * The pointer to the array of origins contained in ORIGIN frame.
4600
+ */
4601
+ nghttp2_origin_entry * ov ;
4602
+ } nghttp2_ext_origin ;
4603
+
4604
+ /**
4605
+ * @function
4606
+ *
4607
+ * Submits ORIGIN frame.
4608
+ *
4609
+ * ORIGIN frame is a non-critical extension to HTTP/2 and defined by
4610
+ * `RFC 8336 <https://tools.ietf.org/html/rfc8336>`_.
4611
+ *
4612
+ * The |flags| is currently ignored and should be
4613
+ * :enum:`NGHTTP2_FLAG_NONE`.
4614
+ *
4615
+ * The |ov| points to the array of origins. The |nov| specifies the
4616
+ * number of origins included in |ov|. This function creates copies
4617
+ * of all elements in |ov|.
4618
+ *
4619
+ * The ORIGIN frame is only usable by a server. If this function is
4620
+ * invoked with client side session, this function returns
4621
+ * :enum:`NGHTTP2_ERR_INVALID_STATE`.
4622
+ *
4623
+ * :enum:`NGHTTP2_ERR_NOMEM`
4624
+ * Out of memory
4625
+ * :enum:`NGHTTP2_ERR_INVALID_STATE`
4626
+ * The function is called from client side session.
4627
+ * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
4628
+ * There are too many origins, or an origin is too large to fit
4629
+ * into a default frame payload.
4630
+ */
4631
+ NGHTTP2_EXTERN int nghttp2_submit_origin (nghttp2_session * session ,
4632
+ uint8_t flags ,
4633
+ const nghttp2_origin_entry * ov ,
4634
+ size_t nov );
4635
+
4554
4636
/**
4555
4637
* @function
4556
4638
*
0 commit comments