2828/* Define WIN32 when build target is Win32 API (borrowed from
2929 libcurl) */
3030#if (defined(_WIN32 ) || defined(__WIN32__ )) && !defined(WIN32 )
31- #define WIN32
31+ # define WIN32
3232#endif
3333
3434#ifdef __cplusplus
@@ -40,30 +40,30 @@ extern "C" {
4040/* MSVC < 2013 does not have inttypes.h because it is not C99
4141 compliant. See compiler macros and version number in
4242 https://sourceforge.net/p/predef/wiki/Compilers/ */
43- #include <stdint.h>
43+ # include <stdint.h>
4444#else /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
45- #include <inttypes.h>
45+ # include <inttypes.h>
4646#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
4747#include <sys/types.h>
4848#include <stdarg.h>
4949
5050#include <nghttp2/nghttp2ver.h>
5151
5252#ifdef NGHTTP2_STATICLIB
53- #define NGHTTP2_EXTERN
53+ # define NGHTTP2_EXTERN
5454#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) */
6767
6868/**
6969 * @macro
@@ -611,7 +611,12 @@ typedef enum {
611611 * The ALTSVC frame, which is defined in `RFC 7383
612612 * <https://tools.ietf.org/html/rfc7838#section-4>`_.
613613 */
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
615620} nghttp2_frame_type ;
616621
617622/**
@@ -2473,15 +2478,15 @@ nghttp2_option_set_no_auto_window_update(nghttp2_option *option, int val);
24732478 *
24742479 * This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
24752480 * 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 .
24852490 */
24862491NGHTTP2_EXTERN void
24872492nghttp2_option_set_peer_max_concurrent_streams (nghttp2_option * option ,
@@ -3797,10 +3802,13 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
37973802 * .. warning::
37983803 *
37993804 * 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
38013806 * frame to that stream ID before
38023807 * :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.
38043812 *
38053813 */
38063814NGHTTP2_EXTERN int32_t nghttp2_submit_request (
@@ -4516,8 +4524,7 @@ typedef struct {
45164524 * Submits ALTSVC frame.
45174525 *
45184526 * 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>`_.
45214528 *
45224529 * The |flags| is currently ignored and should be
45234530 * :enum:`NGHTTP2_FLAG_NONE`.
@@ -4551,6 +4558,81 @@ NGHTTP2_EXTERN int nghttp2_submit_altsvc(nghttp2_session *session,
45514558 const uint8_t * field_value ,
45524559 size_t field_value_len );
45534560
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+
45544636/**
45554637 * @function
45564638 *
0 commit comments