libnghttp2_sys/lib.rs
1#![allow(bad_style)]
2/* automatically generated by rust-bindgen, then hand edited */
3
4#[repr(C)]
5#[derive(Debug, Copy, Clone)]
6pub struct nghttp2_session {
7 _unused: [u8; 0],
8}
9/// @struct
10///
11/// This struct is what `nghttp2_version()` returns. It holds
12/// information about the particular nghttp2 version.
13#[repr(C)]
14#[derive(Debug, Copy, Clone)]
15pub struct nghttp2_info {
16 /// Age of this struct. This instance of nghttp2 sets it to
17 /// :macro:`NGHTTP2_VERSION_AGE` but a future version may bump it and
18 /// add more struct fields at the bottom
19 pub age: ::std::os::raw::c_int,
20 /// the :macro:`NGHTTP2_VERSION_NUM` number (since age ==1)
21 pub version_num: ::std::os::raw::c_int,
22 /// points to the :macro:`NGHTTP2_VERSION` string (since age ==1)
23 pub version_str: *const ::std::os::raw::c_char,
24 /// points to the :macro:`NGHTTP2_PROTO_VERSION_ID` string this
25 /// instance implements (since age ==1)
26 pub proto_str: *const ::std::os::raw::c_char,
27}
28/// Invalid argument passed.
29pub const NGHTTP2_ERR_INVALID_ARGUMENT: nghttp2_error = -501;
30/// Out of buffer space.
31pub const NGHTTP2_ERR_BUFFER_ERROR: nghttp2_error = -502;
32/// The specified protocol version is not supported.
33pub const NGHTTP2_ERR_UNSUPPORTED_VERSION: nghttp2_error = -503;
34/// Used as a return value from :type:`nghttp2_send_callback`,
35/// :type:`nghttp2_recv_callback` and
36/// :type:`nghttp2_send_data_callback` to indicate that the operation
37/// would block.
38pub const NGHTTP2_ERR_WOULDBLOCK: nghttp2_error = -504;
39/// General protocol error
40pub const NGHTTP2_ERR_PROTO: nghttp2_error = -505;
41/// The frame is invalid.
42pub const NGHTTP2_ERR_INVALID_FRAME: nghttp2_error = -506;
43/// The peer performed a shutdown on the connection.
44pub const NGHTTP2_ERR_EOF: nghttp2_error = -507;
45/// Used as a return value from
46/// :func:`nghttp2_data_source_read_callback` to indicate that data
47/// transfer is postponed. See
48/// :func:`nghttp2_data_source_read_callback` for details.
49pub const NGHTTP2_ERR_DEFERRED: nghttp2_error = -508;
50/// Stream ID has reached the maximum value. Therefore no stream ID
51/// is available.
52pub const NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE: nghttp2_error = -509;
53/// The stream is already closed; or the stream ID is invalid.
54pub const NGHTTP2_ERR_STREAM_CLOSED: nghttp2_error = -510;
55/// RST_STREAM has been added to the outbound queue. The stream is
56/// in closing state.
57pub const NGHTTP2_ERR_STREAM_CLOSING: nghttp2_error = -511;
58/// The transmission is not allowed for this stream (e.g., a frame
59/// with END_STREAM flag set has already sent).
60pub const NGHTTP2_ERR_STREAM_SHUT_WR: nghttp2_error = -512;
61/// The stream ID is invalid.
62pub const NGHTTP2_ERR_INVALID_STREAM_ID: nghttp2_error = -513;
63/// The state of the stream is not valid (e.g., DATA cannot be sent
64/// to the stream if response HEADERS has not been sent).
65pub const NGHTTP2_ERR_INVALID_STREAM_STATE: nghttp2_error = -514;
66/// Another DATA frame has already been deferred.
67pub const NGHTTP2_ERR_DEFERRED_DATA_EXIST: nghttp2_error = -515;
68/// Starting new stream is not allowed (e.g., GOAWAY has been sent
69/// and/or received).
70pub const NGHTTP2_ERR_START_STREAM_NOT_ALLOWED: nghttp2_error = -516;
71/// GOAWAY has already been sent.
72pub const NGHTTP2_ERR_GOAWAY_ALREADY_SENT: nghttp2_error = -517;
73/// The received frame contains the invalid header block (e.g., There
74/// are duplicate header names; or the header names are not encoded
75/// in US-ASCII character set and not lower cased; or the header name
76/// is zero-length string; or the header value contains multiple
77/// in-sequence NUL bytes).
78pub const NGHTTP2_ERR_INVALID_HEADER_BLOCK: nghttp2_error = -518;
79/// Indicates that the context is not suitable to perform the
80/// requested operation.
81pub const NGHTTP2_ERR_INVALID_STATE: nghttp2_error = -519;
82/// The user callback function failed due to the temporal error.
83pub const NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE: nghttp2_error = -521;
84/// The length of the frame is invalid, either too large or too small.
85pub const NGHTTP2_ERR_FRAME_SIZE_ERROR: nghttp2_error = -522;
86/// Header block inflate/deflate error.
87pub const NGHTTP2_ERR_HEADER_COMP: nghttp2_error = -523;
88/// Flow control error
89pub const NGHTTP2_ERR_FLOW_CONTROL: nghttp2_error = -524;
90/// Insufficient buffer size given to function.
91pub const NGHTTP2_ERR_INSUFF_BUFSIZE: nghttp2_error = -525;
92/// Callback was paused by the application
93pub const NGHTTP2_ERR_PAUSE: nghttp2_error = -526;
94/// There are too many in-flight SETTING frame and no more
95/// transmission of SETTINGS is allowed.
96pub const NGHTTP2_ERR_TOO_MANY_INFLIGHT_SETTINGS: nghttp2_error = -527;
97/// The server push is disabled.
98pub const NGHTTP2_ERR_PUSH_DISABLED: nghttp2_error = -528;
99/// DATA or HEADERS frame for a given stream has been already
100/// submitted and has not been fully processed yet. Application
101/// should wait for the transmission of the previously submitted
102/// frame before submitting another.
103pub const NGHTTP2_ERR_DATA_EXIST: nghttp2_error = -529;
104/// The current session is closing due to a connection error or
105/// `nghttp2_session_terminate_session()` is called.
106pub const NGHTTP2_ERR_SESSION_CLOSING: nghttp2_error = -530;
107/// Invalid HTTP header field was received and stream is going to be
108/// closed.
109pub const NGHTTP2_ERR_HTTP_HEADER: nghttp2_error = -531;
110/// Violation in HTTP messaging rule.
111pub const NGHTTP2_ERR_HTTP_MESSAGING: nghttp2_error = -532;
112/// Stream was refused.
113pub const NGHTTP2_ERR_REFUSED_STREAM: nghttp2_error = -533;
114/// Unexpected internal error, but recovered.
115pub const NGHTTP2_ERR_INTERNAL: nghttp2_error = -534;
116/// Indicates that a processing was canceled.
117pub const NGHTTP2_ERR_CANCEL: nghttp2_error = -535;
118/// When a local endpoint expects to receive SETTINGS frame, it
119/// receives an other type of frame.
120pub const NGHTTP2_ERR_SETTINGS_EXPECTED: nghttp2_error = -536;
121/// The errors < :enum:`NGHTTP2_ERR_FATAL` mean that the library is
122/// under unexpected condition and processing was terminated (e.g.,
123/// out of memory). If application receives this error code, it must
124/// stop using that :type:`nghttp2_session` object and only allowed
125/// operation for that object is deallocate it using
126/// `nghttp2_session_del()`.
127pub const NGHTTP2_ERR_FATAL: nghttp2_error = -900;
128/// Out of memory. This is a fatal error.
129pub const NGHTTP2_ERR_NOMEM: nghttp2_error = -901;
130/// The user callback function failed. This is a fatal error.
131pub const NGHTTP2_ERR_CALLBACK_FAILURE: nghttp2_error = -902;
132/// Invalid client magic (see :macro:`NGHTTP2_CLIENT_MAGIC`) was
133/// received and further processing is not possible.
134pub const NGHTTP2_ERR_BAD_CLIENT_MAGIC: nghttp2_error = -903;
135/// Possible flooding by peer was detected in this HTTP/2 session.
136/// Flooding is measured by how many PING and SETTINGS frames with
137/// ACK flag set are queued for transmission. These frames are
138/// response for the peer initiated frames, and peer can cause memory
139/// exhaustion on server side to send these frames forever and does
140/// not read network.
141pub const NGHTTP2_ERR_FLOODED: nghttp2_error = -904;
142/// @enum
143///
144/// Error codes used in this library. The code range is [-999, -500],
145/// inclusive. The following values are defined:
146pub type nghttp2_error = i32;
147/// @struct
148///
149/// The object representing single contiguous buffer.
150#[repr(C)]
151#[derive(Debug, Copy, Clone)]
152pub struct nghttp2_vec {
153 /// The pointer to the buffer.
154 pub base: *mut u8,
155 /// The length of the buffer.
156 pub len: usize,
157}
158#[repr(C)]
159#[derive(Debug, Copy, Clone)]
160pub struct nghttp2_rcbuf {
161 _unused: [u8; 0],
162}
163extern "C" {
164 /// @function
165 ///
166 /// Increments the reference count of |rcbuf| by 1.
167 pub fn nghttp2_rcbuf_incref(rcbuf: *mut nghttp2_rcbuf);
168}
169extern "C" {
170 /// @function
171 ///
172 /// Decrements the reference count of |rcbuf| by 1. If the reference
173 /// count becomes zero, the object pointed by |rcbuf| will be freed.
174 /// In this case, application must not use |rcbuf| again.
175 pub fn nghttp2_rcbuf_decref(rcbuf: *mut nghttp2_rcbuf);
176}
177extern "C" {
178 /// @function
179 ///
180 /// Returns the underlying buffer managed by |rcbuf|.
181 pub fn nghttp2_rcbuf_get_buf(rcbuf: *mut nghttp2_rcbuf) -> nghttp2_vec;
182}
183extern "C" {
184 /// @function
185 ///
186 /// Returns nonzero if the underlying buffer is statically allocated,
187 /// and 0 otherwise. This can be useful for language bindings that wish
188 /// to avoid creating duplicate strings for these buffers.
189 pub fn nghttp2_rcbuf_is_static(rcbuf: *const nghttp2_rcbuf) -> ::std::os::raw::c_int;
190}
191/// No flag set.
192pub const NGHTTP2_NV_FLAG_NONE: nghttp2_nv_flag = 0;
193/// Indicates that this name/value pair must not be indexed ("Literal
194/// Header Field never Indexed" representation must be used in HPACK
195/// encoding). Other implementation calls this bit as "sensitive".
196pub const NGHTTP2_NV_FLAG_NO_INDEX: nghttp2_nv_flag = 1;
197/// This flag is set solely by application. If this flag is set, the
198/// library does not make a copy of header field name. This could
199/// improve performance.
200pub const NGHTTP2_NV_FLAG_NO_COPY_NAME: nghttp2_nv_flag = 2;
201/// This flag is set solely by application. If this flag is set, the
202/// library does not make a copy of header field value. This could
203/// improve performance.
204pub const NGHTTP2_NV_FLAG_NO_COPY_VALUE: nghttp2_nv_flag = 4;
205/// @enum
206///
207/// The flags for header field name/value pair.
208pub type nghttp2_nv_flag = u32;
209/// @struct
210///
211/// The name/value pair, which mainly used to represent header fields.
212#[repr(C)]
213#[derive(Debug, Copy, Clone)]
214pub struct nghttp2_nv {
215 /// The |name| byte string. If this struct is presented from library
216 /// (e.g., :type:`nghttp2_on_frame_recv_callback`), |name| is
217 /// guaranteed to be NULL-terminated. For some callbacks
218 /// (:type:`nghttp2_before_frame_send_callback`,
219 /// :type:`nghttp2_on_frame_send_callback`, and
220 /// :type:`nghttp2_on_frame_not_send_callback`), it may not be
221 /// NULL-terminated if header field is passed from application with
222 /// the flag :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`). When application
223 /// is constructing this struct, |name| is not required to be
224 /// NULL-terminated.
225 pub name: *mut u8,
226 /// The |value| byte string. If this struct is presented from
227 /// library (e.g., :type:`nghttp2_on_frame_recv_callback`), |value|
228 /// is guaranteed to be NULL-terminated. For some callbacks
229 /// (:type:`nghttp2_before_frame_send_callback`,
230 /// :type:`nghttp2_on_frame_send_callback`, and
231 /// :type:`nghttp2_on_frame_not_send_callback`), it may not be
232 /// NULL-terminated if header field is passed from application with
233 /// the flag :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE`). When
234 /// application is constructing this struct, |value| is not required
235 /// to be NULL-terminated.
236 pub value: *mut u8,
237 /// The length of the |name|, excluding terminating NULL.
238 pub namelen: usize,
239 /// The length of the |value|, excluding terminating NULL.
240 pub valuelen: usize,
241 /// Bitwise OR of one or more of :type:`nghttp2_nv_flag`.
242 pub flags: u8,
243}
244/// The DATA frame.
245pub const NGHTTP2_DATA: nghttp2_frame_type = 0;
246/// The HEADERS frame.
247pub const NGHTTP2_HEADERS: nghttp2_frame_type = 1;
248/// The PRIORITY frame.
249pub const NGHTTP2_PRIORITY: nghttp2_frame_type = 2;
250/// The RST_STREAM frame.
251pub const NGHTTP2_RST_STREAM: nghttp2_frame_type = 3;
252/// The SETTINGS frame.
253pub const NGHTTP2_SETTINGS: nghttp2_frame_type = 4;
254/// The PUSH_PROMISE frame.
255pub const NGHTTP2_PUSH_PROMISE: nghttp2_frame_type = 5;
256/// The PING frame.
257pub const NGHTTP2_PING: nghttp2_frame_type = 6;
258/// The GOAWAY frame.
259pub const NGHTTP2_GOAWAY: nghttp2_frame_type = 7;
260/// The WINDOW_UPDATE frame.
261pub const NGHTTP2_WINDOW_UPDATE: nghttp2_frame_type = 8;
262/// The CONTINUATION frame. This frame type won't be passed to any
263/// callbacks because the library processes this frame type and its
264/// preceding HEADERS/PUSH_PROMISE as a single frame.
265pub const NGHTTP2_CONTINUATION: nghttp2_frame_type = 9;
266/// The ALTSVC frame, which is defined in `RFC 7383
267/// <https://tools.ietf.org/html/rfc7838#section-4>`_.
268pub const NGHTTP2_ALTSVC: nghttp2_frame_type = 10;
269/// The ORIGIN frame, which is defined by `RFC 8336
270/// <https://tools.ietf.org/html/rfc8336>`_.
271pub const NGHTTP2_ORIGIN: nghttp2_frame_type = 12;
272/// @enum
273///
274/// The frame types in HTTP/2 specification.
275pub type nghttp2_frame_type = u32;
276/// No flag set.
277pub const NGHTTP2_FLAG_NONE: nghttp2_flag = 0;
278/// The END_STREAM flag.
279pub const NGHTTP2_FLAG_END_STREAM: nghttp2_flag = 1;
280/// The END_HEADERS flag.
281pub const NGHTTP2_FLAG_END_HEADERS: nghttp2_flag = 4;
282/// The ACK flag.
283pub const NGHTTP2_FLAG_ACK: nghttp2_flag = 1;
284/// The PADDED flag.
285pub const NGHTTP2_FLAG_PADDED: nghttp2_flag = 8;
286/// The PRIORITY flag.
287pub const NGHTTP2_FLAG_PRIORITY: nghttp2_flag = 32;
288/// @enum
289///
290/// The flags for HTTP/2 frames. This enum defines all flags for all
291/// frames.
292pub type nghttp2_flag = u32;
293/// SETTINGS_HEADER_TABLE_SIZE
294pub const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: nghttp2_settings_id = 1;
295/// SETTINGS_ENABLE_PUSH
296pub const NGHTTP2_SETTINGS_ENABLE_PUSH: nghttp2_settings_id = 2;
297/// SETTINGS_MAX_CONCURRENT_STREAMS
298pub const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: nghttp2_settings_id = 3;
299/// SETTINGS_INITIAL_WINDOW_SIZE
300pub const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: nghttp2_settings_id = 4;
301/// SETTINGS_MAX_FRAME_SIZE
302pub const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: nghttp2_settings_id = 5;
303/// SETTINGS_MAX_HEADER_LIST_SIZE
304pub const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: nghttp2_settings_id = 6;
305/// @enum
306/// The SETTINGS ID.
307pub type nghttp2_settings_id = u32;
308/// No errors.
309pub const NGHTTP2_NO_ERROR: nghttp2_error_code = 0;
310/// PROTOCOL_ERROR
311pub const NGHTTP2_PROTOCOL_ERROR: nghttp2_error_code = 1;
312/// INTERNAL_ERROR
313pub const NGHTTP2_INTERNAL_ERROR: nghttp2_error_code = 2;
314/// FLOW_CONTROL_ERROR
315pub const NGHTTP2_FLOW_CONTROL_ERROR: nghttp2_error_code = 3;
316/// SETTINGS_TIMEOUT
317pub const NGHTTP2_SETTINGS_TIMEOUT: nghttp2_error_code = 4;
318/// STREAM_CLOSED
319pub const NGHTTP2_STREAM_CLOSED: nghttp2_error_code = 5;
320/// FRAME_SIZE_ERROR
321pub const NGHTTP2_FRAME_SIZE_ERROR: nghttp2_error_code = 6;
322/// REFUSED_STREAM
323pub const NGHTTP2_REFUSED_STREAM: nghttp2_error_code = 7;
324/// CANCEL
325pub const NGHTTP2_CANCEL: nghttp2_error_code = 8;
326/// COMPRESSION_ERROR
327pub const NGHTTP2_COMPRESSION_ERROR: nghttp2_error_code = 9;
328/// CONNECT_ERROR
329pub const NGHTTP2_CONNECT_ERROR: nghttp2_error_code = 10;
330/// ENHANCE_YOUR_CALM
331pub const NGHTTP2_ENHANCE_YOUR_CALM: nghttp2_error_code = 11;
332/// INADEQUATE_SECURITY
333pub const NGHTTP2_INADEQUATE_SECURITY: nghttp2_error_code = 12;
334/// HTTP_1_1_REQUIRED
335pub const NGHTTP2_HTTP_1_1_REQUIRED: nghttp2_error_code = 13;
336/// @enum
337/// The status codes for the RST_STREAM and GOAWAY frames.
338pub type nghttp2_error_code = u32;
339/// @struct
340/// The frame header.
341#[repr(C)]
342#[derive(Debug, Copy, Clone)]
343pub struct nghttp2_frame_hd {
344 /// The length field of this frame, excluding frame header.
345 pub length: usize,
346 /// The stream identifier (aka, stream ID)
347 pub stream_id: i32,
348 /// The type of this frame. See `nghttp2_frame_type`.
349 pub type_: u8,
350 /// The flags.
351 pub flags: u8,
352 /// Reserved bit in frame header. Currently, this is always set to 0
353 /// and application should not expect something useful in here.
354 pub reserved: u8,
355}
356/// @union
357///
358/// This union represents the some kind of data source passed to
359/// :type:`nghttp2_data_source_read_callback`.
360#[repr(C)]
361#[derive(Copy, Clone)]
362pub union nghttp2_data_source {
363 /// The integer field, suitable for a file descriptor.
364 pub fd: ::std::os::raw::c_int,
365 /// The pointer to an arbitrary object.
366 pub ptr: *mut ::std::os::raw::c_void,
367 _bindgen_union_align: u64,
368}
369/// No flag set.
370pub const NGHTTP2_DATA_FLAG_NONE: nghttp2_data_flag = 0;
371/// Indicates EOF was sensed.
372pub const NGHTTP2_DATA_FLAG_EOF: nghttp2_data_flag = 1;
373/// Indicates that END_STREAM flag must not be set even if
374/// NGHTTP2_DATA_FLAG_EOF is set. Usually this flag is used to send
375/// trailer fields with `nghttp2_submit_request()` or
376/// `nghttp2_submit_response()`.
377pub const NGHTTP2_DATA_FLAG_NO_END_STREAM: nghttp2_data_flag = 2;
378/// Indicates that application will send complete DATA frame in
379/// :type:`nghttp2_send_data_callback`.
380pub const NGHTTP2_DATA_FLAG_NO_COPY: nghttp2_data_flag = 4;
381/// @enum
382///
383/// The flags used to set in |data_flags| output parameter in
384/// :type:`nghttp2_data_source_read_callback`.
385pub type nghttp2_data_flag = u32;
386/// @functypedef
387///
388/// Callback function invoked when the library wants to read data from
389/// the |source|. The read data is sent in the stream |stream_id|.
390/// The implementation of this function must read at most |length|
391/// bytes of data from |source| (or possibly other places) and store
392/// them in |buf| and return number of data stored in |buf|. If EOF is
393/// reached, set :enum:`NGHTTP2_DATA_FLAG_EOF` flag in |*data_flags|.
394///
395/// Sometime it is desirable to avoid copying data into |buf| and let
396/// application to send data directly. To achieve this, set
397/// :enum:`NGHTTP2_DATA_FLAG_NO_COPY` to |*data_flags| (and possibly
398/// other flags, just like when we do copy), and return the number of
399/// bytes to send without copying data into |buf|. The library, seeing
400/// :enum:`NGHTTP2_DATA_FLAG_NO_COPY`, will invoke
401/// :type:`nghttp2_send_data_callback`. The application must send
402/// complete DATA frame in that callback.
403///
404/// If this callback is set by `nghttp2_submit_request()`,
405/// `nghttp2_submit_response()` or `nghttp2_submit_headers()` and
406/// `nghttp2_submit_data()` with flag parameter
407/// :enum:`NGHTTP2_FLAG_END_STREAM` set, and
408/// :enum:`NGHTTP2_DATA_FLAG_EOF` flag is set to |*data_flags|, DATA
409/// frame will have END_STREAM flag set. Usually, this is expected
410/// behaviour and all are fine. One exception is send trailer fields.
411/// You cannot send trailer fields after sending frame with END_STREAM
412/// set. To avoid this problem, one can set
413/// :enum:`NGHTTP2_DATA_FLAG_NO_END_STREAM` along with
414/// :enum:`NGHTTP2_DATA_FLAG_EOF` to signal the library not to set
415/// END_STREAM in DATA frame. Then application can use
416/// `nghttp2_submit_trailer()` to send trailer fields.
417/// `nghttp2_submit_trailer()` can be called inside this callback.
418///
419/// If the application wants to postpone DATA frames (e.g.,
420/// asynchronous I/O, or reading data blocks for long time), it is
421/// achieved by returning :enum:`NGHTTP2_ERR_DEFERRED` without reading
422/// any data in this invocation. The library removes DATA frame from
423/// the outgoing queue temporarily. To move back deferred DATA frame
424/// to outgoing queue, call `nghttp2_session_resume_data()`.
425///
426/// By default, |length| is limited to 16KiB at maximum. If peer
427/// allows larger frames, application can enlarge transmission buffer
428/// size. See :type:`nghttp2_data_source_read_length_callback` for
429/// more details.
430///
431/// If the application just wants to return from
432/// `nghttp2_session_send()` or `nghttp2_session_mem_send()` without
433/// sending anything, return :enum:`NGHTTP2_ERR_PAUSE`.
434///
435/// In case of error, there are 2 choices. Returning
436/// :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will close the stream
437/// by issuing RST_STREAM with :enum:`NGHTTP2_INTERNAL_ERROR`. If a
438/// different error code is desirable, use
439/// `nghttp2_submit_rst_stream()` with a desired error code and then
440/// return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. Returning
441/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will signal the entire session
442/// failure.
443pub type nghttp2_data_source_read_callback = ::std::option::Option<
444 unsafe extern "C" fn(
445 session: *mut nghttp2_session,
446 stream_id: i32,
447 buf: *mut u8,
448 length: usize,
449 data_flags: *mut u32,
450 source: *mut nghttp2_data_source,
451 user_data: *mut ::std::os::raw::c_void,
452 ) -> isize,
453>;
454/// @struct
455///
456/// This struct represents the data source and the way to read a chunk
457/// of data from it.
458#[repr(C)]
459#[derive(Copy, Clone)]
460pub struct nghttp2_data_provider {
461 /// The data source.
462 pub source: nghttp2_data_source,
463 /// The callback function to read a chunk of data from the |source|.
464 pub read_callback: nghttp2_data_source_read_callback,
465}
466/// @struct
467///
468/// The DATA frame. The received data is delivered via
469/// :type:`nghttp2_on_data_chunk_recv_callback`.
470#[repr(C)]
471#[derive(Debug, Copy, Clone)]
472pub struct nghttp2_data {
473 pub hd: nghttp2_frame_hd,
474 /// The length of the padding in this frame. This includes PAD_HIGH
475 /// and PAD_LOW.
476 pub padlen: usize,
477}
478/// The HEADERS frame is opening new stream, which is analogous to
479/// SYN_STREAM in SPDY.
480pub const NGHTTP2_HCAT_REQUEST: nghttp2_headers_category = 0;
481/// The HEADERS frame is the first response headers, which is
482/// analogous to SYN_REPLY in SPDY.
483pub const NGHTTP2_HCAT_RESPONSE: nghttp2_headers_category = 1;
484/// The HEADERS frame is the first headers sent against reserved
485/// stream.
486pub const NGHTTP2_HCAT_PUSH_RESPONSE: nghttp2_headers_category = 2;
487/// The HEADERS frame which does not apply for the above categories,
488/// which is analogous to HEADERS in SPDY. If non-final response
489/// (e.g., status 1xx) is used, final response HEADERS frame will be
490/// categorized here.
491pub const NGHTTP2_HCAT_HEADERS: nghttp2_headers_category = 3;
492/// @enum
493///
494/// The category of HEADERS, which indicates the role of the frame. In
495/// HTTP/2 spec, request, response, push response and other arbitrary
496/// headers (e.g., trailer fields) are all called just HEADERS. To
497/// give the application the role of incoming HEADERS frame, we define
498/// several categories.
499pub type nghttp2_headers_category = u32;
500/// @struct
501///
502/// The structure to specify stream dependency.
503#[repr(C)]
504#[derive(Debug, Copy, Clone)]
505pub struct nghttp2_priority_spec {
506 /// The stream ID of the stream to depend on. Specifying 0 makes
507 /// stream not depend any other stream.
508 pub stream_id: i32,
509 /// The weight of this dependency.
510 pub weight: i32,
511 /// nonzero means exclusive dependency
512 pub exclusive: u8,
513}
514/// @struct
515///
516/// The HEADERS frame. It has the following members:
517#[repr(C)]
518#[derive(Debug, Copy, Clone)]
519pub struct nghttp2_headers {
520 /// The frame header.
521 pub hd: nghttp2_frame_hd,
522 /// The length of the padding in this frame. This includes PAD_HIGH
523 /// and PAD_LOW.
524 pub padlen: usize,
525 /// The priority specification
526 pub pri_spec: nghttp2_priority_spec,
527 /// The name/value pairs.
528 pub nva: *mut nghttp2_nv,
529 /// The number of name/value pairs in |nva|.
530 pub nvlen: usize,
531 /// The category of this HEADERS frame.
532 pub cat: nghttp2_headers_category,
533}
534/// @struct
535///
536/// The PRIORITY frame. It has the following members:
537#[repr(C)]
538#[derive(Debug, Copy, Clone)]
539pub struct nghttp2_priority {
540 /// The frame header.
541 pub hd: nghttp2_frame_hd,
542 /// The priority specification.
543 pub pri_spec: nghttp2_priority_spec,
544}
545/// @struct
546///
547/// The RST_STREAM frame. It has the following members:
548#[repr(C)]
549#[derive(Debug, Copy, Clone)]
550pub struct nghttp2_rst_stream {
551 /// The frame header.
552 pub hd: nghttp2_frame_hd,
553 /// The error code. See :type:`nghttp2_error_code`.
554 pub error_code: u32,
555}
556/// @struct
557///
558/// The SETTINGS ID/Value pair. It has the following members:
559#[repr(C)]
560#[derive(Debug, Copy, Clone)]
561pub struct nghttp2_settings_entry {
562 /// The SETTINGS ID. See :type:`nghttp2_settings_id`.
563 pub settings_id: i32,
564 /// The value of this entry.
565 pub value: u32,
566}
567/// @struct
568///
569/// The SETTINGS frame. It has the following members:
570#[repr(C)]
571#[derive(Debug, Copy, Clone)]
572pub struct nghttp2_settings {
573 /// The frame header.
574 pub hd: nghttp2_frame_hd,
575 /// The number of SETTINGS ID/Value pairs in |iv|.
576 pub niv: usize,
577 /// The pointer to the array of SETTINGS ID/Value pair.
578 pub iv: *mut nghttp2_settings_entry,
579}
580/// @struct
581///
582/// The PUSH_PROMISE frame. It has the following members:
583#[repr(C)]
584#[derive(Debug, Copy, Clone)]
585pub struct nghttp2_push_promise {
586 /// The frame header.
587 pub hd: nghttp2_frame_hd,
588 /// The length of the padding in this frame. This includes PAD_HIGH
589 /// and PAD_LOW.
590 pub padlen: usize,
591 /// The name/value pairs.
592 pub nva: *mut nghttp2_nv,
593 /// The number of name/value pairs in |nva|.
594 pub nvlen: usize,
595 /// The promised stream ID
596 pub promised_stream_id: i32,
597 /// Reserved bit. Currently this is always set to 0 and application
598 /// should not expect something useful in here.
599 pub reserved: u8,
600}
601/// @struct
602///
603/// The PING frame. It has the following members:
604#[repr(C)]
605#[derive(Debug, Copy, Clone)]
606pub struct nghttp2_ping {
607 /// The frame header.
608 pub hd: nghttp2_frame_hd,
609 /// The opaque data
610 pub opaque_data: [u8; 8usize],
611}
612/// @struct
613///
614/// The GOAWAY frame. It has the following members:
615#[repr(C)]
616#[derive(Debug, Copy, Clone)]
617pub struct nghttp2_goaway {
618 /// The frame header.
619 pub hd: nghttp2_frame_hd,
620 /// The last stream stream ID.
621 pub last_stream_id: i32,
622 /// The error code. See :type:`nghttp2_error_code`.
623 pub error_code: u32,
624 /// The additional debug data
625 pub opaque_data: *mut u8,
626 /// The length of |opaque_data| member.
627 pub opaque_data_len: usize,
628 /// Reserved bit. Currently this is always set to 0 and application
629 /// should not expect something useful in here.
630 pub reserved: u8,
631}
632/// @struct
633///
634/// The WINDOW_UPDATE frame. It has the following members:
635#[repr(C)]
636#[derive(Debug, Copy, Clone)]
637pub struct nghttp2_window_update {
638 /// The frame header.
639 pub hd: nghttp2_frame_hd,
640 /// The window size increment.
641 pub window_size_increment: i32,
642 /// Reserved bit. Currently this is always set to 0 and application
643 /// should not expect something useful in here.
644 pub reserved: u8,
645}
646/// @struct
647///
648/// The extension frame. It has following members:
649#[repr(C)]
650#[derive(Debug, Copy, Clone)]
651pub struct nghttp2_extension {
652 /// The frame header.
653 pub hd: nghttp2_frame_hd,
654 /// The pointer to extension payload. The exact pointer type is
655 /// determined by hd.type.
656 ///
657 /// Currently, no extension is supported. This is a place holder for
658 /// the future extensions.
659 pub payload: *mut ::std::os::raw::c_void,
660}
661/// @union
662///
663/// This union includes all frames to pass them to various function
664/// calls as nghttp2_frame type. The CONTINUATION frame is omitted
665/// from here because the library deals with it internally.
666#[repr(C)]
667#[derive(Copy, Clone)]
668pub union nghttp2_frame {
669 /// The frame header, which is convenient to inspect frame header.
670 pub hd: nghttp2_frame_hd,
671 /// The DATA frame.
672 pub data: nghttp2_data,
673 /// The HEADERS frame.
674 pub headers: nghttp2_headers,
675 /// The PRIORITY frame.
676 pub priority: nghttp2_priority,
677 /// The RST_STREAM frame.
678 pub rst_stream: nghttp2_rst_stream,
679 /// The SETTINGS frame.
680 pub settings: nghttp2_settings,
681 /// The PUSH_PROMISE frame.
682 pub push_promise: nghttp2_push_promise,
683 /// The PING frame.
684 pub ping: nghttp2_ping,
685 /// The GOAWAY frame.
686 pub goaway: nghttp2_goaway,
687 /// The WINDOW_UPDATE frame.
688 pub window_update: nghttp2_window_update,
689 /// The extension frame.
690 pub ext: nghttp2_extension,
691 _bindgen_union_align: [u64; 8usize],
692}
693/// @functypedef
694///
695/// Callback function invoked when |session| wants to send data to the
696/// remote peer. The implementation of this function must send at most
697/// |length| bytes of data stored in |data|. The |flags| is currently
698/// not used and always 0. It must return the number of bytes sent if
699/// it succeeds. If it cannot send any single byte without blocking,
700/// it must return :enum:`NGHTTP2_ERR_WOULDBLOCK`. For other errors,
701/// it must return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. The
702/// |user_data| pointer is the third argument passed in to the call to
703/// `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.
704///
705/// This callback is required if the application uses
706/// `nghttp2_session_send()` to send data to the remote endpoint. If
707/// the application uses solely `nghttp2_session_mem_send()` instead,
708/// this callback function is unnecessary.
709///
710/// To set this callback to :type:`nghttp2_session_callbacks`, use
711/// `nghttp2_session_callbacks_set_send_callback()`.
712///
713/// .. note::
714///
715/// The |length| may be very small. If that is the case, and
716/// application disables Nagle algorithm (``TCP_NODELAY``), then just
717/// writing |data| to the network stack leads to very small packet,
718/// and it is very inefficient. An application should be responsible
719/// to buffer up small chunks of data as necessary to avoid this
720/// situation.
721pub type nghttp2_send_callback = ::std::option::Option<
722 unsafe extern "C" fn(
723 session: *mut nghttp2_session,
724 data: *const u8,
725 length: usize,
726 flags: ::std::os::raw::c_int,
727 user_data: *mut ::std::os::raw::c_void,
728 ) -> isize,
729>;
730/// @functypedef
731///
732/// Callback function invoked when :enum:`NGHTTP2_DATA_FLAG_NO_COPY` is
733/// used in :type:`nghttp2_data_source_read_callback` to send complete
734/// DATA frame.
735///
736/// The |frame| is a DATA frame to send. The |framehd| is the
737/// serialized frame header (9 bytes). The |length| is the length of
738/// application data to send (this does not include padding). The
739/// |source| is the same pointer passed to
740/// :type:`nghttp2_data_source_read_callback`.
741///
742/// The application first must send frame header |framehd| of length 9
743/// bytes. If ``frame->data.padlen > 0``, send 1 byte of value
744/// ``frame->data.padlen - 1``. Then send exactly |length| bytes of
745/// application data. Finally, if ``frame->data.padlen > 1``, send
746/// ``frame->data.padlen - 1`` bytes of zero as padding.
747///
748/// The application has to send complete DATA frame in this callback.
749/// If all data were written successfully, return 0.
750///
751/// If it cannot send any data at all, just return
752/// :enum:`NGHTTP2_ERR_WOULDBLOCK`; the library will call this callback
753/// with the same parameters later (It is recommended to send complete
754/// DATA frame at once in this function to deal with error; if partial
755/// frame data has already sent, it is impossible to send another data
756/// in that state, and all we can do is tear down connection). When
757/// data is fully processed, but application wants to make
758/// `nghttp2_session_mem_send()` or `nghttp2_session_send()` return
759/// immediately without processing next frames, return
760/// :enum:`NGHTTP2_ERR_PAUSE`. If application decided to reset this
761/// stream, return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`, then
762/// the library will send RST_STREAM with INTERNAL_ERROR as error code.
763/// The application can also return
764/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, which will result in
765/// connection closure. Returning any other value is treated as
766/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned.
767pub type nghttp2_send_data_callback = ::std::option::Option<
768 unsafe extern "C" fn(
769 session: *mut nghttp2_session,
770 frame: *mut nghttp2_frame,
771 framehd: *const u8,
772 length: usize,
773 source: *mut nghttp2_data_source,
774 user_data: *mut ::std::os::raw::c_void,
775 ) -> ::std::os::raw::c_int,
776>;
777/// @functypedef
778///
779/// Callback function invoked when |session| wants to receive data from
780/// the remote peer. The implementation of this function must read at
781/// most |length| bytes of data and store it in |buf|. The |flags| is
782/// currently not used and always 0. It must return the number of
783/// bytes written in |buf| if it succeeds. If it cannot read any
784/// single byte without blocking, it must return
785/// :enum:`NGHTTP2_ERR_WOULDBLOCK`. If it gets EOF before it reads any
786/// single byte, it must return :enum:`NGHTTP2_ERR_EOF`. For other
787/// errors, it must return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
788/// Returning 0 is treated as :enum:`NGHTTP2_ERR_WOULDBLOCK`. The
789/// |user_data| pointer is the third argument passed in to the call to
790/// `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.
791///
792/// This callback is required if the application uses
793/// `nghttp2_session_recv()` to receive data from the remote endpoint.
794/// If the application uses solely `nghttp2_session_mem_recv()`
795/// instead, this callback function is unnecessary.
796///
797/// To set this callback to :type:`nghttp2_session_callbacks`, use
798/// `nghttp2_session_callbacks_set_recv_callback()`.
799pub type nghttp2_recv_callback = ::std::option::Option<
800 unsafe extern "C" fn(
801 session: *mut nghttp2_session,
802 buf: *mut u8,
803 length: usize,
804 flags: ::std::os::raw::c_int,
805 user_data: *mut ::std::os::raw::c_void,
806 ) -> isize,
807>;
808/// @functypedef
809///
810/// Callback function invoked by `nghttp2_session_recv()` and
811/// `nghttp2_session_mem_recv()` when a frame is received. The
812/// |user_data| pointer is the third argument passed in to the call to
813/// `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.
814///
815/// If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen``
816/// member of their data structure are always ``NULL`` and 0
817/// respectively. The header name/value pairs are emitted via
818/// :type:`nghttp2_on_header_callback`.
819///
820/// For HEADERS, PUSH_PROMISE and DATA frames, this callback may be
821/// called after stream is closed (see
822/// :type:`nghttp2_on_stream_close_callback`). The application should
823/// check that stream is still alive using its own stream management or
824/// :func:`nghttp2_session_get_stream_user_data()`.
825///
826/// Only HEADERS and DATA frame can signal the end of incoming data.
827/// If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM`` is nonzero, the
828/// |frame| is the last frame from the remote peer in this stream.
829///
830/// This callback won't be called for CONTINUATION frames.
831/// HEADERS/PUSH_PROMISE + CONTINUATIONs are treated as single frame.
832///
833/// The implementation of this function must return 0 if it succeeds.
834/// If nonzero value is returned, it is treated as fatal error and
835/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
836/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
837///
838/// To set this callback to :type:`nghttp2_session_callbacks`, use
839/// `nghttp2_session_callbacks_set_on_frame_recv_callback()`.
840pub type nghttp2_on_frame_recv_callback = ::std::option::Option<
841 unsafe extern "C" fn(
842 session: *mut nghttp2_session,
843 frame: *const nghttp2_frame,
844 user_data: *mut ::std::os::raw::c_void,
845 ) -> ::std::os::raw::c_int,
846>;
847/// @functypedef
848///
849/// Callback function invoked by `nghttp2_session_recv()` and
850/// `nghttp2_session_mem_recv()` when an invalid non-DATA frame is
851/// received. The error is indicated by the |lib_error_code|, which is
852/// one of the values defined in :type:`nghttp2_error`. When this
853/// callback function is invoked, the library automatically submits
854/// either RST_STREAM or GOAWAY frame. The |user_data| pointer is the
855/// third argument passed in to the call to
856/// `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.
857///
858/// If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen``
859/// member of their data structure are always ``NULL`` and 0
860/// respectively.
861///
862/// The implementation of this function must return 0 if it succeeds.
863/// If nonzero is returned, it is treated as fatal error and
864/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
865/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
866///
867/// To set this callback to :type:`nghttp2_session_callbacks`, use
868/// `nghttp2_session_callbacks_set_on_invalid_frame_recv_callback()`.
869pub type nghttp2_on_invalid_frame_recv_callback = ::std::option::Option<
870 unsafe extern "C" fn(
871 session: *mut nghttp2_session,
872 frame: *const nghttp2_frame,
873 lib_error_code: ::std::os::raw::c_int,
874 user_data: *mut ::std::os::raw::c_void,
875 ) -> ::std::os::raw::c_int,
876>;
877/// @functypedef
878///
879/// Callback function invoked when a chunk of data in DATA frame is
880/// received. The |stream_id| is the stream ID this DATA frame belongs
881/// to. The |flags| is the flags of DATA frame which this data chunk
882/// is contained. ``(flags & NGHTTP2_FLAG_END_STREAM) != 0`` does not
883/// necessarily mean this chunk of data is the last one in the stream.
884/// You should use :type:`nghttp2_on_frame_recv_callback` to know all
885/// data frames are received. The |user_data| pointer is the third
886/// argument passed in to the call to `nghttp2_session_client_new()` or
887/// `nghttp2_session_server_new()`.
888///
889/// If the application uses `nghttp2_session_mem_recv()`, it can return
890/// :enum:`NGHTTP2_ERR_PAUSE` to make `nghttp2_session_mem_recv()`
891/// return without processing further input bytes. The memory by
892/// pointed by the |data| is retained until
893/// `nghttp2_session_mem_recv()` or `nghttp2_session_recv()` is called.
894/// The application must retain the input bytes which was used to
895/// produce the |data| parameter, because it may refer to the memory
896/// region included in the input bytes.
897///
898/// The implementation of this function must return 0 if it succeeds.
899/// If nonzero is returned, it is treated as fatal error, and
900/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
901/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
902///
903/// To set this callback to :type:`nghttp2_session_callbacks`, use
904/// `nghttp2_session_callbacks_set_on_data_chunk_recv_callback()`.
905pub type nghttp2_on_data_chunk_recv_callback = ::std::option::Option<
906 unsafe extern "C" fn(
907 session: *mut nghttp2_session,
908 flags: u8,
909 stream_id: i32,
910 data: *const u8,
911 len: usize,
912 user_data: *mut ::std::os::raw::c_void,
913 ) -> ::std::os::raw::c_int,
914>;
915/// @functypedef
916///
917/// Callback function invoked just before the non-DATA frame |frame| is
918/// sent. The |user_data| pointer is the third argument passed in to
919/// the call to `nghttp2_session_client_new()` or
920/// `nghttp2_session_server_new()`.
921///
922/// The implementation of this function must return 0 if it succeeds.
923/// It can also return :enum:`NGHTTP2_ERR_CANCEL` to cancel the
924/// transmission of the given frame.
925///
926/// If there is a fatal error while executing this callback, the
927/// implementation should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`,
928/// which makes `nghttp2_session_send()` and
929/// `nghttp2_session_mem_send()` functions immediately return
930/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
931///
932/// If the other value is returned, it is treated as if
933/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned. But the
934/// implementation should not rely on this since the library may define
935/// new return value to extend its capability.
936///
937/// To set this callback to :type:`nghttp2_session_callbacks`, use
938/// `nghttp2_session_callbacks_set_before_frame_send_callback()`.
939pub type nghttp2_before_frame_send_callback = ::std::option::Option<
940 unsafe extern "C" fn(
941 session: *mut nghttp2_session,
942 frame: *const nghttp2_frame,
943 user_data: *mut ::std::os::raw::c_void,
944 ) -> ::std::os::raw::c_int,
945>;
946/// @functypedef
947///
948/// Callback function invoked after the frame |frame| is sent. The
949/// |user_data| pointer is the third argument passed in to the call to
950/// `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.
951///
952/// The implementation of this function must return 0 if it succeeds.
953/// If nonzero is returned, it is treated as fatal error and
954/// `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions
955/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
956///
957/// To set this callback to :type:`nghttp2_session_callbacks`, use
958/// `nghttp2_session_callbacks_set_on_frame_send_callback()`.
959pub type nghttp2_on_frame_send_callback = ::std::option::Option<
960 unsafe extern "C" fn(
961 session: *mut nghttp2_session,
962 frame: *const nghttp2_frame,
963 user_data: *mut ::std::os::raw::c_void,
964 ) -> ::std::os::raw::c_int,
965>;
966/// @functypedef
967///
968/// Callback function invoked after the non-DATA frame |frame| is not
969/// sent because of the error. The error is indicated by the
970/// |lib_error_code|, which is one of the values defined in
971/// :type:`nghttp2_error`. The |user_data| pointer is the third
972/// argument passed in to the call to `nghttp2_session_client_new()` or
973/// `nghttp2_session_server_new()`.
974///
975/// The implementation of this function must return 0 if it succeeds.
976/// If nonzero is returned, it is treated as fatal error and
977/// `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions
978/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
979///
980/// `nghttp2_session_get_stream_user_data()` can be used to get
981/// associated data.
982///
983/// To set this callback to :type:`nghttp2_session_callbacks`, use
984/// `nghttp2_session_callbacks_set_on_frame_not_send_callback()`.
985pub type nghttp2_on_frame_not_send_callback = ::std::option::Option<
986 unsafe extern "C" fn(
987 session: *mut nghttp2_session,
988 frame: *const nghttp2_frame,
989 lib_error_code: ::std::os::raw::c_int,
990 user_data: *mut ::std::os::raw::c_void,
991 ) -> ::std::os::raw::c_int,
992>;
993/// @functypedef
994///
995/// Callback function invoked when the stream |stream_id| is closed.
996/// The reason of closure is indicated by the |error_code|. The
997/// |error_code| is usually one of :enum:`nghttp2_error_code`, but that
998/// is not guaranteed. The stream_user_data, which was specified in
999/// `nghttp2_submit_request()` or `nghttp2_submit_headers()`, is still
1000/// available in this function. The |user_data| pointer is the third
1001/// argument passed in to the call to `nghttp2_session_client_new()` or
1002/// `nghttp2_session_server_new()`.
1003///
1004/// This function is also called for a stream in reserved state.
1005///
1006/// The implementation of this function must return 0 if it succeeds.
1007/// If nonzero is returned, it is treated as fatal error and
1008/// `nghttp2_session_recv()`, `nghttp2_session_mem_recv()`,
1009/// `nghttp2_session_send()`, and `nghttp2_session_mem_send()`
1010/// functions immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1011///
1012/// To set this callback to :type:`nghttp2_session_callbacks`, use
1013/// `nghttp2_session_callbacks_set_on_stream_close_callback()`.
1014pub type nghttp2_on_stream_close_callback = ::std::option::Option<
1015 unsafe extern "C" fn(
1016 session: *mut nghttp2_session,
1017 stream_id: i32,
1018 error_code: u32,
1019 user_data: *mut ::std::os::raw::c_void,
1020 ) -> ::std::os::raw::c_int,
1021>;
1022/// @functypedef
1023///
1024/// Callback function invoked when the reception of header block in
1025/// HEADERS or PUSH_PROMISE is started. Each header name/value pair
1026/// will be emitted by :type:`nghttp2_on_header_callback`.
1027///
1028/// The ``frame->hd.flags`` may not have
1029/// :enum:`NGHTTP2_FLAG_END_HEADERS` flag set, which indicates that one
1030/// or more CONTINUATION frames are involved. But the application does
1031/// not need to care about that because the header name/value pairs are
1032/// emitted transparently regardless of CONTINUATION frames.
1033///
1034/// The server applications probably create an object to store
1035/// information about new stream if ``frame->hd.type ==
1036/// NGHTTP2_HEADERS`` and ``frame->headers.cat ==
1037/// NGHTTP2_HCAT_REQUEST``. If |session| is configured as server side,
1038/// ``frame->headers.cat`` is either ``NGHTTP2_HCAT_REQUEST``
1039/// containing request headers or ``NGHTTP2_HCAT_HEADERS`` containing
1040/// trailer fields and never get PUSH_PROMISE in this callback.
1041///
1042/// For the client applications, ``frame->hd.type`` is either
1043/// ``NGHTTP2_HEADERS`` or ``NGHTTP2_PUSH_PROMISE``. In case of
1044/// ``NGHTTP2_HEADERS``, ``frame->headers.cat ==
1045/// NGHTTP2_HCAT_RESPONSE`` means that it is the first response
1046/// headers, but it may be non-final response which is indicated by 1xx
1047/// status code. In this case, there may be zero or more HEADERS frame
1048/// with ``frame->headers.cat == NGHTTP2_HCAT_HEADERS`` which has
1049/// non-final response code and finally client gets exactly one HEADERS
1050/// frame with ``frame->headers.cat == NGHTTP2_HCAT_HEADERS``
1051/// containing final response headers (non-1xx status code). The
1052/// trailer fields also has ``frame->headers.cat ==
1053/// NGHTTP2_HCAT_HEADERS`` which does not contain any status code.
1054///
1055/// Returning :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will close
1056/// the stream (promised stream if frame is PUSH_PROMISE) by issuing
1057/// RST_STREAM with :enum:`NGHTTP2_INTERNAL_ERROR`. In this case,
1058/// :type:`nghttp2_on_header_callback` and
1059/// :type:`nghttp2_on_frame_recv_callback` will not be invoked. If a
1060/// different error code is desirable, use
1061/// `nghttp2_submit_rst_stream()` with a desired error code and then
1062/// return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. Again, use
1063/// ``frame->push_promise.promised_stream_id`` as stream_id parameter
1064/// in `nghttp2_submit_rst_stream()` if frame is PUSH_PROMISE.
1065///
1066/// The implementation of this function must return 0 if it succeeds.
1067/// It can return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` to
1068/// reset the stream (promised stream if frame is PUSH_PROMISE). For
1069/// critical errors, it must return
1070/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the other value is
1071/// returned, it is treated as if :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`
1072/// is returned. If :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned,
1073/// `nghttp2_session_mem_recv()` function will immediately return
1074/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1075///
1076/// To set this callback to :type:`nghttp2_session_callbacks`, use
1077/// `nghttp2_session_callbacks_set_on_begin_headers_callback()`.
1078pub type nghttp2_on_begin_headers_callback = ::std::option::Option<
1079 unsafe extern "C" fn(
1080 session: *mut nghttp2_session,
1081 frame: *const nghttp2_frame,
1082 user_data: *mut ::std::os::raw::c_void,
1083 ) -> ::std::os::raw::c_int,
1084>;
1085/// @functypedef
1086///
1087/// Callback function invoked when a header name/value pair is received
1088/// for the |frame|. The |name| of length |namelen| is header name.
1089/// The |value| of length |valuelen| is header value. The |flags| is
1090/// bitwise OR of one or more of :type:`nghttp2_nv_flag`.
1091///
1092/// If :enum:`NGHTTP2_NV_FLAG_NO_INDEX` is set in |flags|, the receiver
1093/// must not index this name/value pair when forwarding it to the next
1094/// hop. More specifically, "Literal Header Field never Indexed"
1095/// representation must be used in HPACK encoding.
1096///
1097/// When this callback is invoked, ``frame->hd.type`` is either
1098/// :enum:`NGHTTP2_HEADERS` or :enum:`NGHTTP2_PUSH_PROMISE`. After all
1099/// header name/value pairs are processed with this callback, and no
1100/// error has been detected, :type:`nghttp2_on_frame_recv_callback`
1101/// will be invoked. If there is an error in decompression,
1102/// :type:`nghttp2_on_frame_recv_callback` for the |frame| will not be
1103/// invoked.
1104///
1105/// Both |name| and |value| are guaranteed to be NULL-terminated. The
1106/// |namelen| and |valuelen| do not include terminal NULL. If
1107/// `nghttp2_option_set_no_http_messaging()` is used with nonzero
1108/// value, NULL character may be included in |name| or |value| before
1109/// terminating NULL.
1110///
1111/// Please note that unless `nghttp2_option_set_no_http_messaging()` is
1112/// used, nghttp2 library does perform validation against the |name|
1113/// and the |value| using `nghttp2_check_header_name()` and
1114/// `nghttp2_check_header_value()`. In addition to this, nghttp2
1115/// performs validation based on HTTP Messaging rule, which is briefly
1116/// explained in :ref:`http-messaging` section.
1117///
1118/// If the application uses `nghttp2_session_mem_recv()`, it can return
1119/// :enum:`NGHTTP2_ERR_PAUSE` to make `nghttp2_session_mem_recv()`
1120/// return without processing further input bytes. The memory pointed
1121/// by |frame|, |name| and |value| parameters are retained until
1122/// `nghttp2_session_mem_recv()` or `nghttp2_session_recv()` is called.
1123/// The application must retain the input bytes which was used to
1124/// produce these parameters, because it may refer to the memory region
1125/// included in the input bytes.
1126///
1127/// Returning :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will close
1128/// the stream (promised stream if frame is PUSH_PROMISE) by issuing
1129/// RST_STREAM with :enum:`NGHTTP2_INTERNAL_ERROR`. In this case,
1130/// :type:`nghttp2_on_header_callback` and
1131/// :type:`nghttp2_on_frame_recv_callback` will not be invoked. If a
1132/// different error code is desirable, use
1133/// `nghttp2_submit_rst_stream()` with a desired error code and then
1134/// return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. Again, use
1135/// ``frame->push_promise.promised_stream_id`` as stream_id parameter
1136/// in `nghttp2_submit_rst_stream()` if frame is PUSH_PROMISE.
1137///
1138/// The implementation of this function must return 0 if it succeeds.
1139/// It may return :enum:`NGHTTP2_ERR_PAUSE` or
1140/// :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. For other critical
1141/// failures, it must return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If
1142/// the other nonzero value is returned, it is treated as
1143/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If
1144/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned,
1145/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
1146/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1147///
1148/// To set this callback to :type:`nghttp2_session_callbacks`, use
1149/// `nghttp2_session_callbacks_set_on_header_callback()`.
1150///
1151/// .. warning::
1152///
1153/// Application should properly limit the total buffer size to store
1154/// incoming header fields. Without it, peer may send large number
1155/// of header fields or large header fields to cause out of memory in
1156/// local endpoint. Due to how HPACK works, peer can do this
1157/// effectively without using much memory on their own.
1158pub type nghttp2_on_header_callback = ::std::option::Option<
1159 unsafe extern "C" fn(
1160 session: *mut nghttp2_session,
1161 frame: *const nghttp2_frame,
1162 name: *const u8,
1163 namelen: usize,
1164 value: *const u8,
1165 valuelen: usize,
1166 flags: u8,
1167 user_data: *mut ::std::os::raw::c_void,
1168 ) -> ::std::os::raw::c_int,
1169>;
1170/// @functypedef
1171///
1172/// Callback function invoked when a header name/value pair is received
1173/// for the |frame|. The |name| is header name. The |value| is header
1174/// value. The |flags| is bitwise OR of one or more of
1175/// :type:`nghttp2_nv_flag`.
1176///
1177/// This callback behaves like :type:`nghttp2_on_header_callback`,
1178/// except that |name| and |value| are stored in reference counted
1179/// buffer. If application wishes to keep these references without
1180/// copying them, use `nghttp2_rcbuf_incref()` to increment their
1181/// reference count. It is the application's responsibility to call
1182/// `nghttp2_rcbuf_decref()` if they called `nghttp2_rcbuf_incref()` so
1183/// as not to leak memory. If the |session| is created by
1184/// `nghttp2_session_server_new3()` or `nghttp2_session_client_new3()`,
1185/// the function to free memory is the one belongs to the mem
1186/// parameter. As long as this free function alives, |name| and
1187/// |value| can live after |session| was destroyed.
1188pub type nghttp2_on_header_callback2 = ::std::option::Option<
1189 unsafe extern "C" fn(
1190 session: *mut nghttp2_session,
1191 frame: *const nghttp2_frame,
1192 name: *mut nghttp2_rcbuf,
1193 value: *mut nghttp2_rcbuf,
1194 flags: u8,
1195 user_data: *mut ::std::os::raw::c_void,
1196 ) -> ::std::os::raw::c_int,
1197>;
1198/// @functypedef
1199///
1200/// Callback function invoked when a invalid header name/value pair is
1201/// received for the |frame|.
1202///
1203/// The parameter and behaviour are similar to
1204/// :type:`nghttp2_on_header_callback`. The difference is that this
1205/// callback is only invoked when a invalid header name/value pair is
1206/// received which is treated as stream error if this callback is not
1207/// set. Only invalid regular header field are passed to this
1208/// callback. In other words, invalid pseudo header field is not
1209/// passed to this callback. Also header fields which includes upper
1210/// cased latter are also treated as error without passing them to this
1211/// callback.
1212///
1213/// This callback is only considered if HTTP messaging validation is
1214/// turned on (which is on by default, see
1215/// `nghttp2_option_set_no_http_messaging()`).
1216///
1217/// With this callback, application inspects the incoming invalid
1218/// field, and it also can reset stream from this callback by returning
1219/// :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By default, the
1220/// error code is :enum:`NGHTTP2_PROTOCOL_ERROR`. To change the error
1221/// code, call `nghttp2_submit_rst_stream()` with the error code of
1222/// choice in addition to returning
1223/// :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`.
1224///
1225/// If 0 is returned, the header field is ignored, and the stream is
1226/// not reset.
1227pub type nghttp2_on_invalid_header_callback = ::std::option::Option<
1228 unsafe extern "C" fn(
1229 session: *mut nghttp2_session,
1230 frame: *const nghttp2_frame,
1231 name: *const u8,
1232 namelen: usize,
1233 value: *const u8,
1234 valuelen: usize,
1235 flags: u8,
1236 user_data: *mut ::std::os::raw::c_void,
1237 ) -> ::std::os::raw::c_int,
1238>;
1239/// @functypedef
1240///
1241/// Callback function invoked when a invalid header name/value pair is
1242/// received for the |frame|.
1243///
1244/// The parameter and behaviour are similar to
1245/// :type:`nghttp2_on_header_callback2`. The difference is that this
1246/// callback is only invoked when a invalid header name/value pair is
1247/// received which is silently ignored if this callback is not set.
1248/// Only invalid regular header field are passed to this callback. In
1249/// other words, invalid pseudo header field is not passed to this
1250/// callback. Also header fields which includes upper cased latter are
1251/// also treated as error without passing them to this callback.
1252///
1253/// This callback is only considered if HTTP messaging validation is
1254/// turned on (which is on by default, see
1255/// `nghttp2_option_set_no_http_messaging()`).
1256///
1257/// With this callback, application inspects the incoming invalid
1258/// field, and it also can reset stream from this callback by returning
1259/// :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By default, the
1260/// error code is :enum:`NGHTTP2_INTERNAL_ERROR`. To change the error
1261/// code, call `nghttp2_submit_rst_stream()` with the error code of
1262/// choice in addition to returning
1263/// :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`.
1264pub type nghttp2_on_invalid_header_callback2 = ::std::option::Option<
1265 unsafe extern "C" fn(
1266 session: *mut nghttp2_session,
1267 frame: *const nghttp2_frame,
1268 name: *mut nghttp2_rcbuf,
1269 value: *mut nghttp2_rcbuf,
1270 flags: u8,
1271 user_data: *mut ::std::os::raw::c_void,
1272 ) -> ::std::os::raw::c_int,
1273>;
1274/// @functypedef
1275///
1276/// Callback function invoked when the library asks application how
1277/// many padding bytes are required for the transmission of the
1278/// |frame|. The application must choose the total length of payload
1279/// including padded bytes in range [frame->hd.length, max_payloadlen],
1280/// inclusive. Choosing number not in this range will be treated as
1281/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Returning
1282/// ``frame->hd.length`` means no padding is added. Returning
1283/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will make
1284/// `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions
1285/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1286///
1287/// To set this callback to :type:`nghttp2_session_callbacks`, use
1288/// `nghttp2_session_callbacks_set_select_padding_callback()`.
1289pub type nghttp2_select_padding_callback = ::std::option::Option<
1290 unsafe extern "C" fn(
1291 session: *mut nghttp2_session,
1292 frame: *const nghttp2_frame,
1293 max_payloadlen: usize,
1294 user_data: *mut ::std::os::raw::c_void,
1295 ) -> isize,
1296>;
1297/// @functypedef
1298///
1299/// Callback function invoked when library wants to get max length of
1300/// data to send data to the remote peer. The implementation of this
1301/// function should return a value in the following range. [1,
1302/// min(|session_remote_window_size|, |stream_remote_window_size|,
1303/// |remote_max_frame_size|)]. If a value greater than this range is
1304/// returned than the max allow value will be used. Returning a value
1305/// smaller than this range is treated as
1306/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. The |frame_type| is provided
1307/// for future extensibility and identifies the type of frame (see
1308/// :type:`nghttp2_frame_type`) for which to get the length for.
1309/// Currently supported frame types are: :enum:`NGHTTP2_DATA`.
1310///
1311/// This callback can be used to control the length in bytes for which
1312/// :type:`nghttp2_data_source_read_callback` is allowed to send to the
1313/// remote endpoint. This callback is optional. Returning
1314/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will signal the entire session
1315/// failure.
1316///
1317/// To set this callback to :type:`nghttp2_session_callbacks`, use
1318/// `nghttp2_session_callbacks_set_data_source_read_length_callback()`.
1319pub type nghttp2_data_source_read_length_callback = ::std::option::Option<
1320 unsafe extern "C" fn(
1321 session: *mut nghttp2_session,
1322 frame_type: u8,
1323 stream_id: i32,
1324 session_remote_window_size: i32,
1325 stream_remote_window_size: i32,
1326 remote_max_frame_size: u32,
1327 user_data: *mut ::std::os::raw::c_void,
1328 ) -> isize,
1329>;
1330/// @functypedef
1331///
1332/// Callback function invoked when a frame header is received. The
1333/// |hd| points to received frame header.
1334///
1335/// Unlike :type:`nghttp2_on_frame_recv_callback`, this callback will
1336/// also be called when frame header of CONTINUATION frame is received.
1337///
1338/// If both :type:`nghttp2_on_begin_frame_callback` and
1339/// :type:`nghttp2_on_begin_headers_callback` are set and HEADERS or
1340/// PUSH_PROMISE is received, :type:`nghttp2_on_begin_frame_callback`
1341/// will be called first.
1342///
1343/// The implementation of this function must return 0 if it succeeds.
1344/// If nonzero value is returned, it is treated as fatal error and
1345/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
1346/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1347///
1348/// To set this callback to :type:`nghttp2_session_callbacks`, use
1349/// `nghttp2_session_callbacks_set_on_begin_frame_callback()`.
1350pub type nghttp2_on_begin_frame_callback = ::std::option::Option<
1351 unsafe extern "C" fn(
1352 session: *mut nghttp2_session,
1353 hd: *const nghttp2_frame_hd,
1354 user_data: *mut ::std::os::raw::c_void,
1355 ) -> ::std::os::raw::c_int,
1356>;
1357/// @functypedef
1358///
1359/// Callback function invoked when chunk of extension frame payload is
1360/// received. The |hd| points to frame header. The received
1361/// chunk is |data| of length |len|.
1362///
1363/// The implementation of this function must return 0 if it succeeds.
1364///
1365/// To abort processing this extension frame, return
1366/// :enum:`NGHTTP2_ERR_CANCEL`.
1367///
1368/// If fatal error occurred, application should return
1369/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
1370/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
1371/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the
1372/// other values are returned, currently they are treated as
1373/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1374pub type nghttp2_on_extension_chunk_recv_callback = ::std::option::Option<
1375 unsafe extern "C" fn(
1376 session: *mut nghttp2_session,
1377 hd: *const nghttp2_frame_hd,
1378 data: *const u8,
1379 len: usize,
1380 user_data: *mut ::std::os::raw::c_void,
1381 ) -> ::std::os::raw::c_int,
1382>;
1383/// @functypedef
1384///
1385/// Callback function invoked when library asks the application to
1386/// unpack extension payload from its wire format. The extension
1387/// payload has been passed to the application using
1388/// :type:`nghttp2_on_extension_chunk_recv_callback`. The frame header
1389/// is already unpacked by the library and provided as |hd|.
1390///
1391/// To receive extension frames, the application must tell desired
1392/// extension frame type to the library using
1393/// `nghttp2_option_set_user_recv_extension_type()`.
1394///
1395/// The implementation of this function may store the pointer to the
1396/// created object as a result of unpacking in |*payload|, and returns
1397/// 0. The pointer stored in |*payload| is opaque to the library, and
1398/// the library does not own its pointer. |*payload| is initialized as
1399/// ``NULL``. The |*payload| is available as ``frame->ext.payload`` in
1400/// :type:`nghttp2_on_frame_recv_callback`. Therefore if application
1401/// can free that memory inside :type:`nghttp2_on_frame_recv_callback`
1402/// callback. Of course, application has a liberty not ot use
1403/// |*payload|, and do its own mechanism to process extension frames.
1404///
1405/// To abort processing this extension frame, return
1406/// :enum:`NGHTTP2_ERR_CANCEL`.
1407///
1408/// If fatal error occurred, application should return
1409/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
1410/// `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions
1411/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the
1412/// other values are returned, currently they are treated as
1413/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1414pub type nghttp2_unpack_extension_callback = ::std::option::Option<
1415 unsafe extern "C" fn(
1416 session: *mut nghttp2_session,
1417 payload: *mut *mut ::std::os::raw::c_void,
1418 hd: *const nghttp2_frame_hd,
1419 user_data: *mut ::std::os::raw::c_void,
1420 ) -> ::std::os::raw::c_int,
1421>;
1422/// @functypedef
1423///
1424/// Callback function invoked when library asks the application to pack
1425/// extension payload in its wire format. The frame header will be
1426/// packed by library. Application must pack payload only.
1427/// ``frame->ext.payload`` is the object passed to
1428/// `nghttp2_submit_extension()` as payload parameter. Application
1429/// must pack extension payload to the |buf| of its capacity |len|
1430/// bytes. The |len| is at least 16KiB.
1431///
1432/// The implementation of this function should return the number of
1433/// bytes written into |buf| when it succeeds.
1434///
1435/// To abort processing this extension frame, return
1436/// :enum:`NGHTTP2_ERR_CANCEL`, and
1437/// :type:`nghttp2_on_frame_not_send_callback` will be invoked.
1438///
1439/// If fatal error occurred, application should return
1440/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
1441/// `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions
1442/// immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the
1443/// other values are returned, currently they are treated as
1444/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the return value is
1445/// strictly larger than |len|, it is treated as
1446/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
1447pub type nghttp2_pack_extension_callback = ::std::option::Option<
1448 unsafe extern "C" fn(
1449 session: *mut nghttp2_session,
1450 buf: *mut u8,
1451 len: usize,
1452 frame: *const nghttp2_frame,
1453 user_data: *mut ::std::os::raw::c_void,
1454 ) -> isize,
1455>;
1456/// @functypedef
1457///
1458/// Callback function invoked when library provides the error message
1459/// intended for human consumption. This callback is solely for
1460/// debugging purpose. The |msg| is typically NULL-terminated string
1461/// of length |len|. |len| does not include the sentinel NULL
1462/// character.
1463///
1464/// This function is deprecated. The new application should use
1465/// :type:`nghttp2_error_callback2`.
1466///
1467/// The format of error message may change between nghttp2 library
1468/// versions. The application should not depend on the particular
1469/// format.
1470///
1471/// Normally, application should return 0 from this callback. If fatal
1472/// error occurred while doing something in this callback, application
1473/// should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
1474/// library will return immediately with return value
1475/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if nonzero value
1476/// is returned from this callback, they are treated as
1477/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, but application should not
1478/// rely on this details.
1479pub type nghttp2_error_callback = ::std::option::Option<
1480 unsafe extern "C" fn(
1481 session: *mut nghttp2_session,
1482 msg: *const ::std::os::raw::c_char,
1483 len: usize,
1484 user_data: *mut ::std::os::raw::c_void,
1485 ) -> ::std::os::raw::c_int,
1486>;
1487/// @functypedef
1488///
1489/// Callback function invoked when library provides the error code, and
1490/// message. This callback is solely for debugging purpose.
1491/// |lib_error_code| is one of error code defined in
1492/// :enum:`nghttp2_error`. The |msg| is typically NULL-terminated
1493/// string of length |len|, and intended for human consumption. |len|
1494/// does not include the sentinel NULL character.
1495///
1496/// The format of error message may change between nghttp2 library
1497/// versions. The application should not depend on the particular
1498/// format.
1499///
1500/// Normally, application should return 0 from this callback. If fatal
1501/// error occurred while doing something in this callback, application
1502/// should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
1503/// library will return immediately with return value
1504/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if nonzero value
1505/// is returned from this callback, they are treated as
1506/// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, but application should not
1507/// rely on this details.
1508pub type nghttp2_error_callback2 = ::std::option::Option<
1509 unsafe extern "C" fn(
1510 session: *mut nghttp2_session,
1511 lib_error_code: ::std::os::raw::c_int,
1512 msg: *const ::std::os::raw::c_char,
1513 len: usize,
1514 user_data: *mut ::std::os::raw::c_void,
1515 ) -> ::std::os::raw::c_int,
1516>;
1517#[repr(C)]
1518#[derive(Debug, Copy, Clone)]
1519pub struct nghttp2_session_callbacks {
1520 _unused: [u8; 0],
1521}
1522extern "C" {
1523 /// @function
1524 ///
1525 /// Initializes |*callbacks_ptr| with NULL values.
1526 ///
1527 /// The initialized object can be used when initializing multiple
1528 /// :type:`nghttp2_session` objects.
1529 ///
1530 /// When the application finished using this object, it can use
1531 /// `nghttp2_session_callbacks_del()` to free its memory.
1532 ///
1533 /// This function returns 0 if it succeeds, or one of the following
1534 /// negative error codes:
1535 ///
1536 /// :enum:`NGHTTP2_ERR_NOMEM`
1537 /// Out of memory.
1538 pub fn nghttp2_session_callbacks_new(
1539 callbacks_ptr: *mut *mut nghttp2_session_callbacks,
1540 ) -> ::std::os::raw::c_int;
1541}
1542extern "C" {
1543 /// @function
1544 ///
1545 /// Frees any resources allocated for |callbacks|. If |callbacks| is
1546 /// ``NULL``, this function does nothing.
1547 pub fn nghttp2_session_callbacks_del(callbacks: *mut nghttp2_session_callbacks);
1548}
1549extern "C" {
1550 /// @function
1551 ///
1552 /// Sets callback function invoked when a session wants to send data to
1553 /// the remote peer. This callback is not necessary if the application
1554 /// uses solely `nghttp2_session_mem_send()` to serialize data to
1555 /// transmit.
1556 pub fn nghttp2_session_callbacks_set_send_callback(
1557 cbs: *mut nghttp2_session_callbacks,
1558 send_callback: nghttp2_send_callback,
1559 );
1560}
1561extern "C" {
1562 /// @function
1563 ///
1564 /// Sets callback function invoked when the a session wants to receive
1565 /// data from the remote peer. This callback is not necessary if the
1566 /// application uses solely `nghttp2_session_mem_recv()` to process
1567 /// received data.
1568 pub fn nghttp2_session_callbacks_set_recv_callback(
1569 cbs: *mut nghttp2_session_callbacks,
1570 recv_callback: nghttp2_recv_callback,
1571 );
1572}
1573extern "C" {
1574 /// @function
1575 ///
1576 /// Sets callback function invoked by `nghttp2_session_recv()` and
1577 /// `nghttp2_session_mem_recv()` when a frame is received.
1578 pub fn nghttp2_session_callbacks_set_on_frame_recv_callback(
1579 cbs: *mut nghttp2_session_callbacks,
1580 on_frame_recv_callback: nghttp2_on_frame_recv_callback,
1581 );
1582}
1583extern "C" {
1584 /// @function
1585 ///
1586 /// Sets callback function invoked by `nghttp2_session_recv()` and
1587 /// `nghttp2_session_mem_recv()` when an invalid non-DATA frame is
1588 /// received.
1589 pub fn nghttp2_session_callbacks_set_on_invalid_frame_recv_callback(
1590 cbs: *mut nghttp2_session_callbacks,
1591 on_invalid_frame_recv_callback: nghttp2_on_invalid_frame_recv_callback,
1592 );
1593}
1594extern "C" {
1595 /// @function
1596 ///
1597 /// Sets callback function invoked when a chunk of data in DATA frame
1598 /// is received.
1599 pub fn nghttp2_session_callbacks_set_on_data_chunk_recv_callback(
1600 cbs: *mut nghttp2_session_callbacks,
1601 on_data_chunk_recv_callback: nghttp2_on_data_chunk_recv_callback,
1602 );
1603}
1604extern "C" {
1605 /// @function
1606 ///
1607 /// Sets callback function invoked before a non-DATA frame is sent.
1608 pub fn nghttp2_session_callbacks_set_before_frame_send_callback(
1609 cbs: *mut nghttp2_session_callbacks,
1610 before_frame_send_callback: nghttp2_before_frame_send_callback,
1611 );
1612}
1613extern "C" {
1614 /// @function
1615 ///
1616 /// Sets callback function invoked after a frame is sent.
1617 pub fn nghttp2_session_callbacks_set_on_frame_send_callback(
1618 cbs: *mut nghttp2_session_callbacks,
1619 on_frame_send_callback: nghttp2_on_frame_send_callback,
1620 );
1621}
1622extern "C" {
1623 /// @function
1624 ///
1625 /// Sets callback function invoked when a non-DATA frame is not sent
1626 /// because of an error.
1627 pub fn nghttp2_session_callbacks_set_on_frame_not_send_callback(
1628 cbs: *mut nghttp2_session_callbacks,
1629 on_frame_not_send_callback: nghttp2_on_frame_not_send_callback,
1630 );
1631}
1632extern "C" {
1633 /// @function
1634 ///
1635 /// Sets callback function invoked when the stream is closed.
1636 pub fn nghttp2_session_callbacks_set_on_stream_close_callback(
1637 cbs: *mut nghttp2_session_callbacks,
1638 on_stream_close_callback: nghttp2_on_stream_close_callback,
1639 );
1640}
1641extern "C" {
1642 /// @function
1643 ///
1644 /// Sets callback function invoked when the reception of header block
1645 /// in HEADERS or PUSH_PROMISE is started.
1646 pub fn nghttp2_session_callbacks_set_on_begin_headers_callback(
1647 cbs: *mut nghttp2_session_callbacks,
1648 on_begin_headers_callback: nghttp2_on_begin_headers_callback,
1649 );
1650}
1651extern "C" {
1652 /// @function
1653 ///
1654 /// Sets callback function invoked when a header name/value pair is
1655 /// received. If both
1656 /// `nghttp2_session_callbacks_set_on_header_callback()` and
1657 /// `nghttp2_session_callbacks_set_on_header_callback2()` are used to
1658 /// set callbacks, the latter has the precedence.
1659 pub fn nghttp2_session_callbacks_set_on_header_callback(
1660 cbs: *mut nghttp2_session_callbacks,
1661 on_header_callback: nghttp2_on_header_callback,
1662 );
1663}
1664extern "C" {
1665 /// @function
1666 ///
1667 /// Sets callback function invoked when a header name/value pair is
1668 /// received.
1669 pub fn nghttp2_session_callbacks_set_on_header_callback2(
1670 cbs: *mut nghttp2_session_callbacks,
1671 on_header_callback2: nghttp2_on_header_callback2,
1672 );
1673}
1674extern "C" {
1675 /// @function
1676 ///
1677 /// Sets callback function invoked when a invalid header name/value
1678 /// pair is received. If both
1679 /// `nghttp2_session_callbacks_set_on_invalid_header_callback()` and
1680 /// `nghttp2_session_callbacks_set_on_invalid_header_callback2()` are
1681 /// used to set callbacks, the latter takes the precedence.
1682 pub fn nghttp2_session_callbacks_set_on_invalid_header_callback(
1683 cbs: *mut nghttp2_session_callbacks,
1684 on_invalid_header_callback: nghttp2_on_invalid_header_callback,
1685 );
1686}
1687extern "C" {
1688 /// @function
1689 ///
1690 /// Sets callback function invoked when a invalid header name/value
1691 /// pair is received.
1692 pub fn nghttp2_session_callbacks_set_on_invalid_header_callback2(
1693 cbs: *mut nghttp2_session_callbacks,
1694 on_invalid_header_callback2: nghttp2_on_invalid_header_callback2,
1695 );
1696}
1697extern "C" {
1698 /// @function
1699 ///
1700 /// Sets callback function invoked when the library asks application
1701 /// how many padding bytes are required for the transmission of the
1702 /// given frame.
1703 pub fn nghttp2_session_callbacks_set_select_padding_callback(
1704 cbs: *mut nghttp2_session_callbacks,
1705 select_padding_callback: nghttp2_select_padding_callback,
1706 );
1707}
1708extern "C" {
1709 /// @function
1710 ///
1711 /// Sets callback function determine the length allowed in
1712 /// :type:`nghttp2_data_source_read_callback`.
1713 pub fn nghttp2_session_callbacks_set_data_source_read_length_callback(
1714 cbs: *mut nghttp2_session_callbacks,
1715 data_source_read_length_callback: nghttp2_data_source_read_length_callback,
1716 );
1717}
1718extern "C" {
1719 /// @function
1720 ///
1721 /// Sets callback function invoked when a frame header is received.
1722 pub fn nghttp2_session_callbacks_set_on_begin_frame_callback(
1723 cbs: *mut nghttp2_session_callbacks,
1724 on_begin_frame_callback: nghttp2_on_begin_frame_callback,
1725 );
1726}
1727extern "C" {
1728 /// @function
1729 ///
1730 /// Sets callback function invoked when
1731 /// :enum:`NGHTTP2_DATA_FLAG_NO_COPY` is used in
1732 /// :type:`nghttp2_data_source_read_callback` to avoid data copy.
1733 pub fn nghttp2_session_callbacks_set_send_data_callback(
1734 cbs: *mut nghttp2_session_callbacks,
1735 send_data_callback: nghttp2_send_data_callback,
1736 );
1737}
1738extern "C" {
1739 /// @function
1740 ///
1741 /// Sets callback function invoked when the library asks the
1742 /// application to pack extension frame payload in wire format.
1743 pub fn nghttp2_session_callbacks_set_pack_extension_callback(
1744 cbs: *mut nghttp2_session_callbacks,
1745 pack_extension_callback: nghttp2_pack_extension_callback,
1746 );
1747}
1748extern "C" {
1749 /// @function
1750 ///
1751 /// Sets callback function invoked when the library asks the
1752 /// application to unpack extension frame payload from wire format.
1753 pub fn nghttp2_session_callbacks_set_unpack_extension_callback(
1754 cbs: *mut nghttp2_session_callbacks,
1755 unpack_extension_callback: nghttp2_unpack_extension_callback,
1756 );
1757}
1758extern "C" {
1759 /// @function
1760 ///
1761 /// Sets callback function invoked when chunk of extension frame
1762 /// payload is received.
1763 pub fn nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(
1764 cbs: *mut nghttp2_session_callbacks,
1765 on_extension_chunk_recv_callback: nghttp2_on_extension_chunk_recv_callback,
1766 );
1767}
1768extern "C" {
1769 /// @function
1770 ///
1771 /// Sets callback function invoked when library tells error message to
1772 /// the application.
1773 ///
1774 /// This function is deprecated. The new application should use
1775 /// `nghttp2_session_callbacks_set_error_callback2()`.
1776 ///
1777 /// If both :type:`nghttp2_error_callback` and
1778 /// :type:`nghttp2_error_callback2` are set, the latter takes
1779 /// precedence.
1780 pub fn nghttp2_session_callbacks_set_error_callback(
1781 cbs: *mut nghttp2_session_callbacks,
1782 error_callback: nghttp2_error_callback,
1783 );
1784}
1785extern "C" {
1786 /// @function
1787 ///
1788 /// Sets callback function invoked when library tells error code, and
1789 /// message to the application.
1790 ///
1791 /// If both :type:`nghttp2_error_callback` and
1792 /// :type:`nghttp2_error_callback2` are set, the latter takes
1793 /// precedence.
1794 pub fn nghttp2_session_callbacks_set_error_callback2(
1795 cbs: *mut nghttp2_session_callbacks,
1796 error_callback2: nghttp2_error_callback2,
1797 );
1798}
1799/// @functypedef
1800///
1801/// Custom memory allocator to replace malloc(). The |mem_user_data|
1802/// is the mem_user_data member of :type:`nghttp2_mem` structure.
1803pub type nghttp2_malloc = ::std::option::Option<
1804 unsafe extern "C" fn(
1805 size: usize,
1806 mem_user_data: *mut ::std::os::raw::c_void,
1807 ) -> *mut ::std::os::raw::c_void,
1808>;
1809/// @functypedef
1810///
1811/// Custom memory allocator to replace free(). The |mem_user_data| is
1812/// the mem_user_data member of :type:`nghttp2_mem` structure.
1813pub type nghttp2_free = ::std::option::Option<
1814 unsafe extern "C" fn(
1815 ptr: *mut ::std::os::raw::c_void,
1816 mem_user_data: *mut ::std::os::raw::c_void,
1817 ),
1818>;
1819/// @functypedef
1820///
1821/// Custom memory allocator to replace calloc(). The |mem_user_data|
1822/// is the mem_user_data member of :type:`nghttp2_mem` structure.
1823pub type nghttp2_calloc = ::std::option::Option<
1824 unsafe extern "C" fn(
1825 nmemb: usize,
1826 size: usize,
1827 mem_user_data: *mut ::std::os::raw::c_void,
1828 ) -> *mut ::std::os::raw::c_void,
1829>;
1830/// @functypedef
1831///
1832/// Custom memory allocator to replace realloc(). The |mem_user_data|
1833/// is the mem_user_data member of :type:`nghttp2_mem` structure.
1834pub type nghttp2_realloc = ::std::option::Option<
1835 unsafe extern "C" fn(
1836 ptr: *mut ::std::os::raw::c_void,
1837 size: usize,
1838 mem_user_data: *mut ::std::os::raw::c_void,
1839 ) -> *mut ::std::os::raw::c_void,
1840>;
1841/// @struct
1842///
1843/// Custom memory allocator functions and user defined pointer. The
1844/// |mem_user_data| member is passed to each allocator function. This
1845/// can be used, for example, to achieve per-session memory pool.
1846///
1847/// In the following example code, ``my_malloc``, ``my_free``,
1848/// ``my_calloc`` and ``my_realloc`` are the replacement of the
1849/// standard allocators ``malloc``, ``free``, ``calloc`` and
1850/// ``realloc`` respectively::
1851///
1852/// void *my_malloc_cb(size_t size, void *mem_user_data) {
1853/// return my_malloc(size);
1854/// }
1855///
1856/// void my_free_cb(void *ptr, void *mem_user_data) { my_free(ptr); }
1857///
1858/// void *my_calloc_cb(size_t nmemb, size_t size, void *mem_user_data) {
1859/// return my_calloc(nmemb, size);
1860/// }
1861///
1862/// void *my_realloc_cb(void *ptr, size_t size, void *mem_user_data) {
1863/// return my_realloc(ptr, size);
1864/// }
1865///
1866/// void session_new() {
1867/// nghttp2_session *session;
1868/// nghttp2_session_callbacks *callbacks;
1869/// nghttp2_mem mem = {NULL, my_malloc_cb, my_free_cb, my_calloc_cb,
1870/// my_realloc_cb};
1871///
1872/// ...
1873///
1874/// nghttp2_session_client_new3(&session, callbacks, NULL, NULL, &mem);
1875///
1876/// ...
1877/// }
1878#[repr(C)]
1879#[derive(Debug, Copy, Clone)]
1880pub struct nghttp2_mem {
1881 /// An arbitrary user supplied data. This is passed to each
1882 /// allocator function.
1883 pub mem_user_data: *mut ::std::os::raw::c_void,
1884 /// Custom allocator function to replace malloc().
1885 pub malloc: nghttp2_malloc,
1886 /// Custom allocator function to replace free().
1887 pub free: nghttp2_free,
1888 /// Custom allocator function to replace calloc().
1889 pub calloc: nghttp2_calloc,
1890 /// Custom allocator function to replace realloc().
1891 pub realloc: nghttp2_realloc,
1892}
1893#[repr(C)]
1894#[derive(Debug, Copy, Clone)]
1895pub struct nghttp2_option {
1896 _unused: [u8; 0],
1897}
1898extern "C" {
1899 /// @function
1900 ///
1901 /// Initializes |*option_ptr| with default values.
1902 ///
1903 /// When the application finished using this object, it can use
1904 /// `nghttp2_option_del()` to free its memory.
1905 ///
1906 /// This function returns 0 if it succeeds, or one of the following
1907 /// negative error codes:
1908 ///
1909 /// :enum:`NGHTTP2_ERR_NOMEM`
1910 /// Out of memory.
1911 pub fn nghttp2_option_new(option_ptr: *mut *mut nghttp2_option) -> ::std::os::raw::c_int;
1912}
1913extern "C" {
1914 /// @function
1915 ///
1916 /// Frees any resources allocated for |option|. If |option| is
1917 /// ``NULL``, this function does nothing.
1918 pub fn nghttp2_option_del(option: *mut nghttp2_option);
1919}
1920extern "C" {
1921 /// @function
1922 ///
1923 /// This option prevents the library from sending WINDOW_UPDATE for a
1924 /// connection automatically. If this option is set to nonzero, the
1925 /// library won't send WINDOW_UPDATE for DATA until application calls
1926 /// `nghttp2_session_consume()` to indicate the consumed amount of
1927 /// data. Don't use `nghttp2_submit_window_update()` for this purpose.
1928 /// By default, this option is set to zero.
1929 pub fn nghttp2_option_set_no_auto_window_update(
1930 option: *mut nghttp2_option,
1931 val: ::std::os::raw::c_int,
1932 );
1933}
1934extern "C" {
1935 /// @function
1936 ///
1937 /// This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
1938 /// remote endpoint as if it is received in SETTINGS frame. Without
1939 /// specifying this option, the maximum number of outgoing concurrent
1940 /// streams is initially limited to 100 to avoid issues when the local
1941 /// endpoint submits lots of requests before receiving initial SETTINGS
1942 /// frame from the remote endpoint, since sending them at once to the
1943 /// remote endpoint could lead to rejection of some of the requests.
1944 /// This value will be overwritten when the local endpoint receives
1945 /// initial SETTINGS frame from the remote endpoint, either to the
1946 /// value advertised in SETTINGS_MAX_CONCURRENT_STREAMS or to the
1947 /// default value (unlimited) if none was advertised.
1948 pub fn nghttp2_option_set_peer_max_concurrent_streams(option: *mut nghttp2_option, val: u32);
1949}
1950extern "C" {
1951 /// @function
1952 ///
1953 /// By default, nghttp2 library, if configured as server, requires
1954 /// first 24 bytes of client magic byte string (MAGIC). In most cases,
1955 /// this will simplify the implementation of server. But sometimes
1956 /// server may want to detect the application protocol based on first
1957 /// few bytes on clear text communication.
1958 ///
1959 /// If this option is used with nonzero |val|, nghttp2 library does not
1960 /// handle MAGIC. It still checks following SETTINGS frame. This
1961 /// means that applications should deal with MAGIC by themselves.
1962 ///
1963 /// If this option is not used or used with zero value, if MAGIC does
1964 /// not match :macro:`NGHTTP2_CLIENT_MAGIC`, `nghttp2_session_recv()`
1965 /// and `nghttp2_session_mem_recv()` will return error
1966 /// :enum:`NGHTTP2_ERR_BAD_CLIENT_MAGIC`, which is fatal error.
1967 pub fn nghttp2_option_set_no_recv_client_magic(
1968 option: *mut nghttp2_option,
1969 val: ::std::os::raw::c_int,
1970 );
1971}
1972extern "C" {
1973 /// @function
1974 ///
1975 /// By default, nghttp2 library enforces subset of HTTP Messaging rules
1976 /// described in `HTTP/2 specification, section 8
1977 /// <https://tools.ietf.org/html/rfc7540#section-8>`_. See
1978 /// :ref:`http-messaging` section for details. For those applications
1979 /// who use nghttp2 library as non-HTTP use, give nonzero to |val| to
1980 /// disable this enforcement. Please note that disabling this feature
1981 /// does not change the fundamental client and server model of HTTP.
1982 /// That is, even if the validation is disabled, only client can send
1983 /// requests.
1984 pub fn nghttp2_option_set_no_http_messaging(
1985 option: *mut nghttp2_option,
1986 val: ::std::os::raw::c_int,
1987 );
1988}
1989extern "C" {
1990 /// @function
1991 ///
1992 /// RFC 7540 does not enforce any limit on the number of incoming
1993 /// reserved streams (in RFC 7540 terms, streams in reserved (remote)
1994 /// state). This only affects client side, since only server can push
1995 /// streams. Malicious server can push arbitrary number of streams,
1996 /// and make client's memory exhausted. This option can set the
1997 /// maximum number of such incoming streams to avoid possible memory
1998 /// exhaustion. If this option is set, and pushed streams are
1999 /// automatically closed on reception, without calling user provided
2000 /// callback, if they exceed the given limit. The default value is
2001 /// 200. If session is configured as server side, this option has no
2002 /// effect. Server can control the number of streams to push.
2003 pub fn nghttp2_option_set_max_reserved_remote_streams(option: *mut nghttp2_option, val: u32);
2004}
2005extern "C" {
2006 /// @function
2007 ///
2008 /// Sets extension frame type the application is willing to handle with
2009 /// user defined callbacks (see
2010 /// :type:`nghttp2_on_extension_chunk_recv_callback` and
2011 /// :type:`nghttp2_unpack_extension_callback`). The |type| is
2012 /// extension frame type, and must be strictly greater than 0x9.
2013 /// Otherwise, this function does nothing. The application can call
2014 /// this function multiple times to set more than one frame type to
2015 /// receive. The application does not have to call this function if it
2016 /// just sends extension frames.
2017 pub fn nghttp2_option_set_user_recv_extension_type(option: *mut nghttp2_option, type_: u8);
2018}
2019extern "C" {
2020 /// @function
2021 ///
2022 /// Sets extension frame type the application is willing to receive
2023 /// using builtin handler. The |type| is the extension frame type to
2024 /// receive, and must be strictly greater than 0x9. Otherwise, this
2025 /// function does nothing. The application can call this function
2026 /// multiple times to set more than one frame type to receive. The
2027 /// application does not have to call this function if it just sends
2028 /// extension frames.
2029 ///
2030 /// If same frame type is passed to both
2031 /// `nghttp2_option_set_builtin_recv_extension_type()` and
2032 /// `nghttp2_option_set_user_recv_extension_type()`, the latter takes
2033 /// precedence.
2034 pub fn nghttp2_option_set_builtin_recv_extension_type(option: *mut nghttp2_option, type_: u8);
2035}
2036extern "C" {
2037 /// @function
2038 ///
2039 /// This option prevents the library from sending PING frame with ACK
2040 /// flag set automatically when PING frame without ACK flag set is
2041 /// received. If this option is set to nonzero, the library won't send
2042 /// PING frame with ACK flag set in the response for incoming PING
2043 /// frame. The application can send PING frame with ACK flag set using
2044 /// `nghttp2_submit_ping()` with :enum:`NGHTTP2_FLAG_ACK` as flags
2045 /// parameter.
2046 pub fn nghttp2_option_set_no_auto_ping_ack(
2047 option: *mut nghttp2_option,
2048 val: ::std::os::raw::c_int,
2049 );
2050}
2051extern "C" {
2052 /// @function
2053 ///
2054 /// This option sets the maximum length of header block (a set of
2055 /// header fields per one HEADERS frame) to send. The length of a
2056 /// given set of header fields is calculated using
2057 /// `nghttp2_hd_deflate_bound()`. The default value is 64KiB. If
2058 /// application attempts to send header fields larger than this limit,
2059 /// the transmission of the frame fails with error code
2060 /// :enum:`NGHTTP2_ERR_FRAME_SIZE_ERROR`.
2061 pub fn nghttp2_option_set_max_send_header_block_length(option: *mut nghttp2_option, val: usize);
2062}
2063extern "C" {
2064 /// @function
2065 ///
2066 /// This option sets the maximum dynamic table size for deflating
2067 /// header fields. The default value is 4KiB. In HTTP/2, receiver of
2068 /// deflated header block can specify maximum dynamic table size. The
2069 /// actual maximum size is the minimum of the size receiver specified
2070 /// and this option value.
2071 pub fn nghttp2_option_set_max_deflate_dynamic_table_size(
2072 option: *mut nghttp2_option,
2073 val: usize,
2074 );
2075}
2076extern "C" {
2077 /// @function
2078 ///
2079 /// This option prevents the library from retaining closed streams to
2080 /// maintain the priority tree. If this option is set to nonzero,
2081 /// applications can discard closed stream completely to save memory.
2082 pub fn nghttp2_option_set_no_closed_streams(
2083 option: *mut nghttp2_option,
2084 val: ::std::os::raw::c_int,
2085 );
2086}
2087extern "C" {
2088 /// @function
2089 ///
2090 /// Initializes |*session_ptr| for client use. The all members of
2091 /// |callbacks| are copied to |*session_ptr|. Therefore |*session_ptr|
2092 /// does not store |callbacks|. The |user_data| is an arbitrary user
2093 /// supplied data, which will be passed to the callback functions.
2094 ///
2095 /// The :type:`nghttp2_send_callback` must be specified. If the
2096 /// application code uses `nghttp2_session_recv()`, the
2097 /// :type:`nghttp2_recv_callback` must be specified. The other members
2098 /// of |callbacks| can be ``NULL``.
2099 ///
2100 /// If this function fails, |*session_ptr| is left untouched.
2101 ///
2102 /// This function returns 0 if it succeeds, or one of the following
2103 /// negative error codes:
2104 ///
2105 /// :enum:`NGHTTP2_ERR_NOMEM`
2106 /// Out of memory.
2107 pub fn nghttp2_session_client_new(
2108 session_ptr: *mut *mut nghttp2_session,
2109 callbacks: *const nghttp2_session_callbacks,
2110 user_data: *mut ::std::os::raw::c_void,
2111 ) -> ::std::os::raw::c_int;
2112}
2113extern "C" {
2114 /// @function
2115 ///
2116 /// Initializes |*session_ptr| for server use. The all members of
2117 /// |callbacks| are copied to |*session_ptr|. Therefore |*session_ptr|
2118 /// does not store |callbacks|. The |user_data| is an arbitrary user
2119 /// supplied data, which will be passed to the callback functions.
2120 ///
2121 /// The :type:`nghttp2_send_callback` must be specified. If the
2122 /// application code uses `nghttp2_session_recv()`, the
2123 /// :type:`nghttp2_recv_callback` must be specified. The other members
2124 /// of |callbacks| can be ``NULL``.
2125 ///
2126 /// If this function fails, |*session_ptr| is left untouched.
2127 ///
2128 /// This function returns 0 if it succeeds, or one of the following
2129 /// negative error codes:
2130 ///
2131 /// :enum:`NGHTTP2_ERR_NOMEM`
2132 /// Out of memory.
2133 pub fn nghttp2_session_server_new(
2134 session_ptr: *mut *mut nghttp2_session,
2135 callbacks: *const nghttp2_session_callbacks,
2136 user_data: *mut ::std::os::raw::c_void,
2137 ) -> ::std::os::raw::c_int;
2138}
2139extern "C" {
2140 /// @function
2141 ///
2142 /// Like `nghttp2_session_client_new()`, but with additional options
2143 /// specified in the |option|.
2144 ///
2145 /// The |option| can be ``NULL`` and the call is equivalent to
2146 /// `nghttp2_session_client_new()`.
2147 ///
2148 /// This function does not take ownership |option|. The application is
2149 /// responsible for freeing |option| if it finishes using the object.
2150 ///
2151 /// The library code does not refer to |option| after this function
2152 /// returns.
2153 ///
2154 /// This function returns 0 if it succeeds, or one of the following
2155 /// negative error codes:
2156 ///
2157 /// :enum:`NGHTTP2_ERR_NOMEM`
2158 /// Out of memory.
2159 pub fn nghttp2_session_client_new2(
2160 session_ptr: *mut *mut nghttp2_session,
2161 callbacks: *const nghttp2_session_callbacks,
2162 user_data: *mut ::std::os::raw::c_void,
2163 option: *const nghttp2_option,
2164 ) -> ::std::os::raw::c_int;
2165}
2166extern "C" {
2167 /// @function
2168 ///
2169 /// Like `nghttp2_session_server_new()`, but with additional options
2170 /// specified in the |option|.
2171 ///
2172 /// The |option| can be ``NULL`` and the call is equivalent to
2173 /// `nghttp2_session_server_new()`.
2174 ///
2175 /// This function does not take ownership |option|. The application is
2176 /// responsible for freeing |option| if it finishes using the object.
2177 ///
2178 /// The library code does not refer to |option| after this function
2179 /// returns.
2180 ///
2181 /// This function returns 0 if it succeeds, or one of the following
2182 /// negative error codes:
2183 ///
2184 /// :enum:`NGHTTP2_ERR_NOMEM`
2185 /// Out of memory.
2186 pub fn nghttp2_session_server_new2(
2187 session_ptr: *mut *mut nghttp2_session,
2188 callbacks: *const nghttp2_session_callbacks,
2189 user_data: *mut ::std::os::raw::c_void,
2190 option: *const nghttp2_option,
2191 ) -> ::std::os::raw::c_int;
2192}
2193extern "C" {
2194 /// @function
2195 ///
2196 /// Like `nghttp2_session_client_new2()`, but with additional custom
2197 /// memory allocator specified in the |mem|.
2198 ///
2199 /// The |mem| can be ``NULL`` and the call is equivalent to
2200 /// `nghttp2_session_client_new2()`.
2201 ///
2202 /// This function does not take ownership |mem|. The application is
2203 /// responsible for freeing |mem|.
2204 ///
2205 /// The library code does not refer to |mem| pointer after this
2206 /// function returns, so the application can safely free it.
2207 ///
2208 /// This function returns 0 if it succeeds, or one of the following
2209 /// negative error codes:
2210 ///
2211 /// :enum:`NGHTTP2_ERR_NOMEM`
2212 /// Out of memory.
2213 pub fn nghttp2_session_client_new3(
2214 session_ptr: *mut *mut nghttp2_session,
2215 callbacks: *const nghttp2_session_callbacks,
2216 user_data: *mut ::std::os::raw::c_void,
2217 option: *const nghttp2_option,
2218 mem: *mut nghttp2_mem,
2219 ) -> ::std::os::raw::c_int;
2220}
2221extern "C" {
2222 /// @function
2223 ///
2224 /// Like `nghttp2_session_server_new2()`, but with additional custom
2225 /// memory allocator specified in the |mem|.
2226 ///
2227 /// The |mem| can be ``NULL`` and the call is equivalent to
2228 /// `nghttp2_session_server_new2()`.
2229 ///
2230 /// This function does not take ownership |mem|. The application is
2231 /// responsible for freeing |mem|.
2232 ///
2233 /// The library code does not refer to |mem| pointer after this
2234 /// function returns, so the application can safely free it.
2235 ///
2236 /// This function returns 0 if it succeeds, or one of the following
2237 /// negative error codes:
2238 ///
2239 /// :enum:`NGHTTP2_ERR_NOMEM`
2240 /// Out of memory.
2241 pub fn nghttp2_session_server_new3(
2242 session_ptr: *mut *mut nghttp2_session,
2243 callbacks: *const nghttp2_session_callbacks,
2244 user_data: *mut ::std::os::raw::c_void,
2245 option: *const nghttp2_option,
2246 mem: *mut nghttp2_mem,
2247 ) -> ::std::os::raw::c_int;
2248}
2249extern "C" {
2250 /// @function
2251 ///
2252 /// Frees any resources allocated for |session|. If |session| is
2253 /// ``NULL``, this function does nothing.
2254 pub fn nghttp2_session_del(session: *mut nghttp2_session);
2255}
2256extern "C" {
2257 /// @function
2258 ///
2259 /// Sends pending frames to the remote peer.
2260 ///
2261 /// This function retrieves the highest prioritized frame from the
2262 /// outbound queue and sends it to the remote peer. It does this as
2263 /// many as possible until the user callback
2264 /// :type:`nghttp2_send_callback` returns
2265 /// :enum:`NGHTTP2_ERR_WOULDBLOCK` or the outbound queue becomes empty.
2266 /// This function calls several callback functions which are passed
2267 /// when initializing the |session|. Here is the simple time chart
2268 /// which tells when each callback is invoked:
2269 ///
2270 /// 1. Get the next frame to send from outbound queue.
2271 ///
2272 /// 2. Prepare transmission of the frame.
2273 ///
2274 /// 3. If the control frame cannot be sent because some preconditions
2275 /// are not met (e.g., request HEADERS cannot be sent after GOAWAY),
2276 /// :type:`nghttp2_on_frame_not_send_callback` is invoked. Abort
2277 /// the following steps.
2278 ///
2279 /// 4. If the frame is HEADERS, PUSH_PROMISE or DATA,
2280 /// :type:`nghttp2_select_padding_callback` is invoked.
2281 ///
2282 /// 5. If the frame is request HEADERS, the stream is opened here.
2283 ///
2284 /// 6. :type:`nghttp2_before_frame_send_callback` is invoked.
2285 ///
2286 /// 7. If :enum:`NGHTTP2_ERR_CANCEL` is returned from
2287 /// :type:`nghttp2_before_frame_send_callback`, the current frame
2288 /// transmission is canceled, and
2289 /// :type:`nghttp2_on_frame_not_send_callback` is invoked. Abort
2290 /// the following steps.
2291 ///
2292 /// 8. :type:`nghttp2_send_callback` is invoked one or more times to
2293 /// send the frame.
2294 ///
2295 /// 9. :type:`nghttp2_on_frame_send_callback` is invoked.
2296 ///
2297 /// 10. If the transmission of the frame triggers closure of the
2298 /// stream, the stream is closed and
2299 /// :type:`nghttp2_on_stream_close_callback` is invoked.
2300 ///
2301 /// This function returns 0 if it succeeds, or one of the following
2302 /// negative error codes:
2303 ///
2304 /// :enum:`NGHTTP2_ERR_NOMEM`
2305 /// Out of memory.
2306 /// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`
2307 /// The callback function failed.
2308 pub fn nghttp2_session_send(session: *mut nghttp2_session) -> ::std::os::raw::c_int;
2309}
2310extern "C" {
2311 /// @function
2312 ///
2313 /// Returns the serialized data to send.
2314 ///
2315 /// This function behaves like `nghttp2_session_send()` except that it
2316 /// does not use :type:`nghttp2_send_callback` to transmit data.
2317 /// Instead, it assigns the pointer to the serialized data to the
2318 /// |*data_ptr| and returns its length. The other callbacks are called
2319 /// in the same way as they are in `nghttp2_session_send()`.
2320 ///
2321 /// If no data is available to send, this function returns 0.
2322 ///
2323 /// This function may not return all serialized data in one invocation.
2324 /// To get all data, call this function repeatedly until it returns 0
2325 /// or one of negative error codes.
2326 ///
2327 /// The assigned |*data_ptr| is valid until the next call of
2328 /// `nghttp2_session_mem_send()` or `nghttp2_session_send()`.
2329 ///
2330 /// The caller must send all data before sending the next chunk of
2331 /// data.
2332 ///
2333 /// This function returns the length of the data pointed by the
2334 /// |*data_ptr| if it succeeds, or one of the following negative error
2335 /// codes:
2336 ///
2337 /// :enum:`NGHTTP2_ERR_NOMEM`
2338 /// Out of memory.
2339 ///
2340 /// .. note::
2341 ///
2342 /// This function may produce very small byte string. If that is the
2343 /// case, and application disables Nagle algorithm (``TCP_NODELAY``),
2344 /// then writing this small chunk leads to very small packet, and it
2345 /// is very inefficient. An application should be responsible to
2346 /// buffer up small chunks of data as necessary to avoid this
2347 /// situation.
2348 pub fn nghttp2_session_mem_send(
2349 session: *mut nghttp2_session,
2350 data_ptr: *mut *const u8,
2351 ) -> isize;
2352}
2353extern "C" {
2354 /// @function
2355 ///
2356 /// Receives frames from the remote peer.
2357 ///
2358 /// This function receives as many frames as possible until the user
2359 /// callback :type:`nghttp2_recv_callback` returns
2360 /// :enum:`NGHTTP2_ERR_WOULDBLOCK`. This function calls several
2361 /// callback functions which are passed when initializing the
2362 /// |session|. Here is the simple time chart which tells when each
2363 /// callback is invoked:
2364 ///
2365 /// 1. :type:`nghttp2_recv_callback` is invoked one or more times to
2366 /// receive frame header.
2367 ///
2368 /// 2. When frame header is received,
2369 /// :type:`nghttp2_on_begin_frame_callback` is invoked.
2370 ///
2371 /// 3. If the frame is DATA frame:
2372 ///
2373 /// 1. :type:`nghttp2_recv_callback` is invoked to receive DATA
2374 /// payload. For each chunk of data,
2375 /// :type:`nghttp2_on_data_chunk_recv_callback` is invoked.
2376 ///
2377 /// 2. If one DATA frame is completely received,
2378 /// :type:`nghttp2_on_frame_recv_callback` is invoked. If the
2379 /// reception of the frame triggers the closure of the stream,
2380 /// :type:`nghttp2_on_stream_close_callback` is invoked.
2381 ///
2382 /// 4. If the frame is the control frame:
2383 ///
2384 /// 1. :type:`nghttp2_recv_callback` is invoked one or more times to
2385 /// receive whole frame.
2386 ///
2387 /// 2. If the received frame is valid, then following actions are
2388 /// taken. If the frame is either HEADERS or PUSH_PROMISE,
2389 /// :type:`nghttp2_on_begin_headers_callback` is invoked. Then
2390 /// :type:`nghttp2_on_header_callback` is invoked for each header
2391 /// name/value pair. For invalid header field,
2392 /// :type:`nghttp2_on_invalid_header_callback` is called. After
2393 /// all name/value pairs are emitted successfully,
2394 /// :type:`nghttp2_on_frame_recv_callback` is invoked. For other
2395 /// frames, :type:`nghttp2_on_frame_recv_callback` is invoked.
2396 /// If the reception of the frame triggers the closure of the
2397 /// stream, :type:`nghttp2_on_stream_close_callback` is invoked.
2398 ///
2399 /// 3. If the received frame is unpacked but is interpreted as
2400 /// invalid, :type:`nghttp2_on_invalid_frame_recv_callback` is
2401 /// invoked.
2402 ///
2403 /// This function returns 0 if it succeeds, or one of the following
2404 /// negative error codes:
2405 ///
2406 /// :enum:`NGHTTP2_ERR_EOF`
2407 /// The remote peer did shutdown on the connection.
2408 /// :enum:`NGHTTP2_ERR_NOMEM`
2409 /// Out of memory.
2410 /// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`
2411 /// The callback function failed.
2412 /// :enum:`NGHTTP2_ERR_BAD_CLIENT_MAGIC`
2413 /// Invalid client magic was detected. This error only returns
2414 /// when |session| was configured as server and
2415 /// `nghttp2_option_set_no_recv_client_magic()` is not used with
2416 /// nonzero value.
2417 /// :enum:`NGHTTP2_ERR_FLOODED`
2418 /// Flooding was detected in this HTTP/2 session, and it must be
2419 /// closed. This is most likely caused by misbehaviour of peer.
2420 pub fn nghttp2_session_recv(session: *mut nghttp2_session) -> ::std::os::raw::c_int;
2421}
2422extern "C" {
2423 /// @function
2424 ///
2425 /// Processes data |in| as an input from the remote endpoint. The
2426 /// |inlen| indicates the number of bytes in the |in|.
2427 ///
2428 /// This function behaves like `nghttp2_session_recv()` except that it
2429 /// does not use :type:`nghttp2_recv_callback` to receive data; the
2430 /// |in| is the only data for the invocation of this function. If all
2431 /// bytes are processed, this function returns. The other callbacks
2432 /// are called in the same way as they are in `nghttp2_session_recv()`.
2433 ///
2434 /// In the current implementation, this function always tries to
2435 /// processes all input data unless either an error occurs or
2436 /// :enum:`NGHTTP2_ERR_PAUSE` is returned from
2437 /// :type:`nghttp2_on_header_callback` or
2438 /// :type:`nghttp2_on_data_chunk_recv_callback`. If
2439 /// :enum:`NGHTTP2_ERR_PAUSE` is used, the return value includes the
2440 /// number of bytes which was used to produce the data or frame for the
2441 /// callback.
2442 ///
2443 /// This function returns the number of processed bytes, or one of the
2444 /// following negative error codes:
2445 ///
2446 /// :enum:`NGHTTP2_ERR_NOMEM`
2447 /// Out of memory.
2448 /// :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`
2449 /// The callback function failed.
2450 /// :enum:`NGHTTP2_ERR_BAD_CLIENT_MAGIC`
2451 /// Invalid client magic was detected. This error only returns
2452 /// when |session| was configured as server and
2453 /// `nghttp2_option_set_no_recv_client_magic()` is not used with
2454 /// nonzero value.
2455 /// :enum:`NGHTTP2_ERR_FLOODED`
2456 /// Flooding was detected in this HTTP/2 session, and it must be
2457 /// closed. This is most likely caused by misbehaviour of peer.
2458 pub fn nghttp2_session_mem_recv(
2459 session: *mut nghttp2_session,
2460 in_: *const u8,
2461 inlen: usize,
2462 ) -> isize;
2463}
2464extern "C" {
2465 /// @function
2466 ///
2467 /// Puts back previously deferred DATA frame in the stream |stream_id|
2468 /// to the outbound queue.
2469 ///
2470 /// This function returns 0 if it succeeds, or one of the following
2471 /// negative error codes:
2472 ///
2473 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2474 /// The stream does not exist; or no deferred data exist.
2475 /// :enum:`NGHTTP2_ERR_NOMEM`
2476 /// Out of memory.
2477 pub fn nghttp2_session_resume_data(
2478 session: *mut nghttp2_session,
2479 stream_id: i32,
2480 ) -> ::std::os::raw::c_int;
2481}
2482extern "C" {
2483 /// @function
2484 ///
2485 /// Returns nonzero value if |session| wants to receive data from the
2486 /// remote peer.
2487 ///
2488 /// If both `nghttp2_session_want_read()` and
2489 /// `nghttp2_session_want_write()` return 0, the application should
2490 /// drop the connection.
2491 pub fn nghttp2_session_want_read(session: *mut nghttp2_session) -> ::std::os::raw::c_int;
2492}
2493extern "C" {
2494 /// @function
2495 ///
2496 /// Returns nonzero value if |session| wants to send data to the remote
2497 /// peer.
2498 ///
2499 /// If both `nghttp2_session_want_read()` and
2500 /// `nghttp2_session_want_write()` return 0, the application should
2501 /// drop the connection.
2502 pub fn nghttp2_session_want_write(session: *mut nghttp2_session) -> ::std::os::raw::c_int;
2503}
2504extern "C" {
2505 /// @function
2506 ///
2507 /// Returns stream_user_data for the stream |stream_id|. The
2508 /// stream_user_data is provided by `nghttp2_submit_request()`,
2509 /// `nghttp2_submit_headers()` or
2510 /// `nghttp2_session_set_stream_user_data()`. Unless it is set using
2511 /// `nghttp2_session_set_stream_user_data()`, if the stream is
2512 /// initiated by the remote endpoint, stream_user_data is always
2513 /// ``NULL``. If the stream does not exist, this function returns
2514 /// ``NULL``.
2515 pub fn nghttp2_session_get_stream_user_data(
2516 session: *mut nghttp2_session,
2517 stream_id: i32,
2518 ) -> *mut ::std::os::raw::c_void;
2519}
2520extern "C" {
2521 /// @function
2522 ///
2523 /// Sets the |stream_user_data| to the stream denoted by the
2524 /// |stream_id|. If a stream user data is already set to the stream,
2525 /// it is replaced with the |stream_user_data|. It is valid to specify
2526 /// ``NULL`` in the |stream_user_data|, which nullifies the associated
2527 /// data pointer.
2528 ///
2529 /// It is valid to set the |stream_user_data| to the stream reserved by
2530 /// PUSH_PROMISE frame.
2531 ///
2532 /// This function returns 0 if it succeeds, or one of following
2533 /// negative error codes:
2534 ///
2535 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2536 /// The stream does not exist
2537 pub fn nghttp2_session_set_stream_user_data(
2538 session: *mut nghttp2_session,
2539 stream_id: i32,
2540 stream_user_data: *mut ::std::os::raw::c_void,
2541 ) -> ::std::os::raw::c_int;
2542}
2543extern "C" {
2544 /// @function
2545 ///
2546 /// Sets |user_data| to |session|, overwriting the existing user data
2547 /// specified in `nghttp2_session_client_new()`, or
2548 /// `nghttp2_session_server_new()`.
2549 pub fn nghttp2_session_set_user_data(
2550 session: *mut nghttp2_session,
2551 user_data: *mut ::std::os::raw::c_void,
2552 );
2553}
2554extern "C" {
2555 /// @function
2556 ///
2557 /// Returns the number of frames in the outbound queue. This does not
2558 /// include the deferred DATA frames.
2559 pub fn nghttp2_session_get_outbound_queue_size(session: *mut nghttp2_session) -> usize;
2560}
2561extern "C" {
2562 /// @function
2563 ///
2564 /// Returns the number of DATA payload in bytes received without
2565 /// WINDOW_UPDATE transmission for the stream |stream_id|. The local
2566 /// (receive) window size can be adjusted by
2567 /// `nghttp2_submit_window_update()`. This function takes into account
2568 /// that and returns effective data length. In particular, if the
2569 /// local window size is reduced by submitting negative
2570 /// window_size_increment with `nghttp2_submit_window_update()`, this
2571 /// function returns the number of bytes less than actually received.
2572 ///
2573 /// This function returns -1 if it fails.
2574 pub fn nghttp2_session_get_stream_effective_recv_data_length(
2575 session: *mut nghttp2_session,
2576 stream_id: i32,
2577 ) -> i32;
2578}
2579extern "C" {
2580 /// @function
2581 ///
2582 /// Returns the local (receive) window size for the stream |stream_id|.
2583 /// The local window size can be adjusted by
2584 /// `nghttp2_submit_window_update()`. This function takes into account
2585 /// that and returns effective window size.
2586 ///
2587 /// This function does not take into account the amount of received
2588 /// data from the remote endpoint. Use
2589 /// `nghttp2_session_get_stream_local_window_size()` to know the amount
2590 /// of data the remote endpoint can send without receiving stream level
2591 /// WINDOW_UPDATE frame. Note that each stream is still subject to the
2592 /// connection level flow control.
2593 ///
2594 /// This function returns -1 if it fails.
2595 pub fn nghttp2_session_get_stream_effective_local_window_size(
2596 session: *mut nghttp2_session,
2597 stream_id: i32,
2598 ) -> i32;
2599}
2600extern "C" {
2601 /// @function
2602 ///
2603 /// Returns the amount of flow-controlled payload (e.g., DATA) that the
2604 /// remote endpoint can send without receiving stream level
2605 /// WINDOW_UPDATE frame. It is also subject to the connection level
2606 /// flow control. So the actual amount of data to send is
2607 /// min(`nghttp2_session_get_stream_local_window_size()`,
2608 /// `nghttp2_session_get_local_window_size()`).
2609 ///
2610 /// This function returns -1 if it fails.
2611 pub fn nghttp2_session_get_stream_local_window_size(
2612 session: *mut nghttp2_session,
2613 stream_id: i32,
2614 ) -> i32;
2615}
2616extern "C" {
2617 /// @function
2618 ///
2619 /// Returns the number of DATA payload in bytes received without
2620 /// WINDOW_UPDATE transmission for a connection. The local (receive)
2621 /// window size can be adjusted by `nghttp2_submit_window_update()`.
2622 /// This function takes into account that and returns effective data
2623 /// length. In particular, if the local window size is reduced by
2624 /// submitting negative window_size_increment with
2625 /// `nghttp2_submit_window_update()`, this function returns the number
2626 /// of bytes less than actually received.
2627 ///
2628 /// This function returns -1 if it fails.
2629 pub fn nghttp2_session_get_effective_recv_data_length(session: *mut nghttp2_session) -> i32;
2630}
2631extern "C" {
2632 /// @function
2633 ///
2634 /// Returns the local (receive) window size for a connection. The
2635 /// local window size can be adjusted by
2636 /// `nghttp2_submit_window_update()`. This function takes into account
2637 /// that and returns effective window size.
2638 ///
2639 /// This function does not take into account the amount of received
2640 /// data from the remote endpoint. Use
2641 /// `nghttp2_session_get_local_window_size()` to know the amount of
2642 /// data the remote endpoint can send without receiving
2643 /// connection-level WINDOW_UPDATE frame. Note that each stream is
2644 /// still subject to the stream level flow control.
2645 ///
2646 /// This function returns -1 if it fails.
2647 pub fn nghttp2_session_get_effective_local_window_size(session: *mut nghttp2_session) -> i32;
2648}
2649extern "C" {
2650 /// @function
2651 ///
2652 /// Returns the amount of flow-controlled payload (e.g., DATA) that the
2653 /// remote endpoint can send without receiving connection level
2654 /// WINDOW_UPDATE frame. Note that each stream is still subject to the
2655 /// stream level flow control (see
2656 /// `nghttp2_session_get_stream_local_window_size()`).
2657 ///
2658 /// This function returns -1 if it fails.
2659 pub fn nghttp2_session_get_local_window_size(session: *mut nghttp2_session) -> i32;
2660}
2661extern "C" {
2662 /// @function
2663 ///
2664 /// Returns the remote window size for a given stream |stream_id|.
2665 ///
2666 /// This is the amount of flow-controlled payload (e.g., DATA) that the
2667 /// local endpoint can send without stream level WINDOW_UPDATE. There
2668 /// is also connection level flow control, so the effective size of
2669 /// payload that the local endpoint can actually send is
2670 /// min(`nghttp2_session_get_stream_remote_window_size()`,
2671 /// `nghttp2_session_get_remote_window_size()`).
2672 ///
2673 /// This function returns -1 if it fails.
2674 pub fn nghttp2_session_get_stream_remote_window_size(
2675 session: *mut nghttp2_session,
2676 stream_id: i32,
2677 ) -> i32;
2678}
2679extern "C" {
2680 /// @function
2681 ///
2682 /// Returns the remote window size for a connection.
2683 ///
2684 /// This function always succeeds.
2685 pub fn nghttp2_session_get_remote_window_size(session: *mut nghttp2_session) -> i32;
2686}
2687extern "C" {
2688 /// @function
2689 ///
2690 /// Returns 1 if local peer half closed the given stream |stream_id|.
2691 /// Returns 0 if it did not. Returns -1 if no such stream exists.
2692 pub fn nghttp2_session_get_stream_local_close(
2693 session: *mut nghttp2_session,
2694 stream_id: i32,
2695 ) -> ::std::os::raw::c_int;
2696}
2697extern "C" {
2698 /// @function
2699 ///
2700 /// Returns 1 if remote peer half closed the given stream |stream_id|.
2701 /// Returns 0 if it did not. Returns -1 if no such stream exists.
2702 pub fn nghttp2_session_get_stream_remote_close(
2703 session: *mut nghttp2_session,
2704 stream_id: i32,
2705 ) -> ::std::os::raw::c_int;
2706}
2707extern "C" {
2708 /// @function
2709 ///
2710 /// Returns the current dynamic table size of HPACK inflater, including
2711 /// the overhead 32 bytes per entry described in RFC 7541.
2712 pub fn nghttp2_session_get_hd_inflate_dynamic_table_size(
2713 session: *mut nghttp2_session,
2714 ) -> usize;
2715}
2716extern "C" {
2717 /// @function
2718 ///
2719 /// Returns the current dynamic table size of HPACK deflater including
2720 /// the overhead 32 bytes per entry described in RFC 7541.
2721 pub fn nghttp2_session_get_hd_deflate_dynamic_table_size(
2722 session: *mut nghttp2_session,
2723 ) -> usize;
2724}
2725extern "C" {
2726 /// @function
2727 ///
2728 /// Signals the session so that the connection should be terminated.
2729 ///
2730 /// The last stream ID is the minimum value between the stream ID of a
2731 /// stream for which :type:`nghttp2_on_frame_recv_callback` was called
2732 /// most recently and the last stream ID we have sent to the peer
2733 /// previously.
2734 ///
2735 /// The |error_code| is the error code of this GOAWAY frame. The
2736 /// pre-defined error code is one of :enum:`nghttp2_error_code`.
2737 ///
2738 /// After the transmission, both `nghttp2_session_want_read()` and
2739 /// `nghttp2_session_want_write()` return 0.
2740 ///
2741 /// This function should be called when the connection should be
2742 /// terminated after sending GOAWAY. If the remaining streams should
2743 /// be processed after GOAWAY, use `nghttp2_submit_goaway()` instead.
2744 ///
2745 /// This function returns 0 if it succeeds, or one of the following
2746 /// negative error codes:
2747 ///
2748 /// :enum:`NGHTTP2_ERR_NOMEM`
2749 /// Out of memory.
2750 pub fn nghttp2_session_terminate_session(
2751 session: *mut nghttp2_session,
2752 error_code: u32,
2753 ) -> ::std::os::raw::c_int;
2754}
2755extern "C" {
2756 /// @function
2757 ///
2758 /// Signals the session so that the connection should be terminated.
2759 ///
2760 /// This function behaves like `nghttp2_session_terminate_session()`,
2761 /// but the last stream ID can be specified by the application for fine
2762 /// grained control of stream. The HTTP/2 specification does not allow
2763 /// last_stream_id to be increased. So the actual value sent as
2764 /// last_stream_id is the minimum value between the given
2765 /// |last_stream_id| and the last_stream_id we have previously sent to
2766 /// the peer.
2767 ///
2768 /// The |last_stream_id| is peer's stream ID or 0. So if |session| is
2769 /// initialized as client, |last_stream_id| must be even or 0. If
2770 /// |session| is initialized as server, |last_stream_id| must be odd or
2771 /// 0.
2772 ///
2773 /// This function returns 0 if it succeeds, or one of the following
2774 /// negative error codes:
2775 ///
2776 /// :enum:`NGHTTP2_ERR_NOMEM`
2777 /// Out of memory.
2778 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2779 /// The |last_stream_id| is invalid.
2780 pub fn nghttp2_session_terminate_session2(
2781 session: *mut nghttp2_session,
2782 last_stream_id: i32,
2783 error_code: u32,
2784 ) -> ::std::os::raw::c_int;
2785}
2786extern "C" {
2787 /// @function
2788 ///
2789 /// Signals to the client that the server started graceful shutdown
2790 /// procedure.
2791 ///
2792 /// This function is only usable for server. If this function is
2793 /// called with client side session, this function returns
2794 /// :enum:`NGHTTP2_ERR_INVALID_STATE`.
2795 ///
2796 /// To gracefully shutdown HTTP/2 session, server should call this
2797 /// function to send GOAWAY with last_stream_id (1u << 31) - 1. And
2798 /// after some delay (e.g., 1 RTT), send another GOAWAY with the stream
2799 /// ID that the server has some processing using
2800 /// `nghttp2_submit_goaway()`. See also
2801 /// `nghttp2_session_get_last_proc_stream_id()`.
2802 ///
2803 /// Unlike `nghttp2_submit_goaway()`, this function just sends GOAWAY
2804 /// and does nothing more. This is a mere indication to the client
2805 /// that session shutdown is imminent. The application should call
2806 /// `nghttp2_submit_goaway()` with appropriate last_stream_id after
2807 /// this call.
2808 ///
2809 /// If one or more GOAWAY frame have been already sent by either
2810 /// `nghttp2_submit_goaway()` or `nghttp2_session_terminate_session()`,
2811 /// this function has no effect.
2812 ///
2813 /// This function returns 0 if it succeeds, or one of the following
2814 /// negative error codes:
2815 ///
2816 /// :enum:`NGHTTP2_ERR_NOMEM`
2817 /// Out of memory.
2818 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
2819 /// The |session| is initialized as client.
2820 pub fn nghttp2_submit_shutdown_notice(session: *mut nghttp2_session) -> ::std::os::raw::c_int;
2821}
2822extern "C" {
2823 /// @function
2824 ///
2825 /// Returns the value of SETTINGS |id| notified by a remote endpoint.
2826 /// The |id| must be one of values defined in
2827 /// :enum:`nghttp2_settings_id`.
2828 pub fn nghttp2_session_get_remote_settings(
2829 session: *mut nghttp2_session,
2830 id: nghttp2_settings_id,
2831 ) -> u32;
2832}
2833extern "C" {
2834 /// @function
2835 ///
2836 /// Returns the value of SETTINGS |id| of local endpoint acknowledged
2837 /// by the remote endpoint. The |id| must be one of the values defined
2838 /// in :enum:`nghttp2_settings_id`.
2839 pub fn nghttp2_session_get_local_settings(
2840 session: *mut nghttp2_session,
2841 id: nghttp2_settings_id,
2842 ) -> u32;
2843}
2844extern "C" {
2845 /// @function
2846 ///
2847 /// Tells the |session| that next stream ID is |next_stream_id|. The
2848 /// |next_stream_id| must be equal or greater than the value returned
2849 /// by `nghttp2_session_get_next_stream_id()`.
2850 ///
2851 /// This function returns 0 if it succeeds, or one of the following
2852 /// negative error codes:
2853 ///
2854 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2855 /// The |next_stream_id| is strictly less than the value
2856 /// `nghttp2_session_get_next_stream_id()` returns; or
2857 /// |next_stream_id| is invalid (e.g., even integer for client, or
2858 /// odd integer for server).
2859 pub fn nghttp2_session_set_next_stream_id(
2860 session: *mut nghttp2_session,
2861 next_stream_id: i32,
2862 ) -> ::std::os::raw::c_int;
2863}
2864extern "C" {
2865 /// @function
2866 ///
2867 /// Returns the next outgoing stream ID. Notice that return type is
2868 /// uint32_t. If we run out of stream ID for this session, this
2869 /// function returns 1 << 31.
2870 pub fn nghttp2_session_get_next_stream_id(session: *mut nghttp2_session) -> u32;
2871}
2872extern "C" {
2873 /// @function
2874 ///
2875 /// Tells the |session| that |size| bytes for a stream denoted by
2876 /// |stream_id| were consumed by application and are ready to
2877 /// WINDOW_UPDATE. The consumed bytes are counted towards both
2878 /// connection and stream level WINDOW_UPDATE (see
2879 /// `nghttp2_session_consume_connection()` and
2880 /// `nghttp2_session_consume_stream()` to update consumption
2881 /// independently). This function is intended to be used without
2882 /// automatic window update (see
2883 /// `nghttp2_option_set_no_auto_window_update()`).
2884 ///
2885 /// This function returns 0 if it succeeds, or one of the following
2886 /// negative error codes:
2887 ///
2888 /// :enum:`NGHTTP2_ERR_NOMEM`
2889 /// Out of memory.
2890 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2891 /// The |stream_id| is 0.
2892 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
2893 /// Automatic WINDOW_UPDATE is not disabled.
2894 pub fn nghttp2_session_consume(
2895 session: *mut nghttp2_session,
2896 stream_id: i32,
2897 size: usize,
2898 ) -> ::std::os::raw::c_int;
2899}
2900extern "C" {
2901 /// @function
2902 ///
2903 /// Like `nghttp2_session_consume()`, but this only tells library that
2904 /// |size| bytes were consumed only for connection level. Note that
2905 /// HTTP/2 maintains connection and stream level flow control windows
2906 /// independently.
2907 ///
2908 /// This function returns 0 if it succeeds, or one of the following
2909 /// negative error codes:
2910 ///
2911 /// :enum:`NGHTTP2_ERR_NOMEM`
2912 /// Out of memory.
2913 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
2914 /// Automatic WINDOW_UPDATE is not disabled.
2915 pub fn nghttp2_session_consume_connection(
2916 session: *mut nghttp2_session,
2917 size: usize,
2918 ) -> ::std::os::raw::c_int;
2919}
2920extern "C" {
2921 /// @function
2922 ///
2923 /// Like `nghttp2_session_consume()`, but this only tells library that
2924 /// |size| bytes were consumed only for stream denoted by |stream_id|.
2925 /// Note that HTTP/2 maintains connection and stream level flow control
2926 /// windows independently.
2927 ///
2928 /// This function returns 0 if it succeeds, or one of the following
2929 /// negative error codes:
2930 ///
2931 /// :enum:`NGHTTP2_ERR_NOMEM`
2932 /// Out of memory.
2933 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2934 /// The |stream_id| is 0.
2935 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
2936 /// Automatic WINDOW_UPDATE is not disabled.
2937 pub fn nghttp2_session_consume_stream(
2938 session: *mut nghttp2_session,
2939 stream_id: i32,
2940 size: usize,
2941 ) -> ::std::os::raw::c_int;
2942}
2943extern "C" {
2944 /// @function
2945 ///
2946 /// Changes priority of existing stream denoted by |stream_id|. The
2947 /// new priority specification is |pri_spec|.
2948 ///
2949 /// The priority is changed silently and instantly, and no PRIORITY
2950 /// frame will be sent to notify the peer of this change. This
2951 /// function may be useful for server to change the priority of pushed
2952 /// stream.
2953 ///
2954 /// If |session| is initialized as server, and ``pri_spec->stream_id``
2955 /// points to the idle stream, the idle stream is created if it does
2956 /// not exist. The created idle stream will depend on root stream
2957 /// (stream 0) with weight 16.
2958 ///
2959 /// Otherwise, if stream denoted by ``pri_spec->stream_id`` is not
2960 /// found, we use default priority instead of given |pri_spec|. That
2961 /// is make stream depend on root stream with weight 16.
2962 ///
2963 /// This function returns 0 if it succeeds, or one of the following
2964 /// negative error codes:
2965 ///
2966 /// :enum:`NGHTTP2_ERR_NOMEM`
2967 /// Out of memory.
2968 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
2969 /// Attempted to depend on itself; or no stream exist for the given
2970 /// |stream_id|; or |stream_id| is 0
2971 pub fn nghttp2_session_change_stream_priority(
2972 session: *mut nghttp2_session,
2973 stream_id: i32,
2974 pri_spec: *const nghttp2_priority_spec,
2975 ) -> ::std::os::raw::c_int;
2976}
2977extern "C" {
2978 /// @function
2979 ///
2980 /// Creates idle stream with the given |stream_id|, and priority
2981 /// |pri_spec|.
2982 ///
2983 /// The stream creation is done without sending PRIORITY frame, which
2984 /// means that peer does not know about the existence of this idle
2985 /// stream in the local endpoint.
2986 ///
2987 /// RFC 7540 does not disallow the use of creation of idle stream with
2988 /// odd or even stream ID regardless of client or server. So this
2989 /// function can create odd or even stream ID regardless of client or
2990 /// server. But probably it is a bit safer to use the stream ID the
2991 /// local endpoint can initiate (in other words, use odd stream ID for
2992 /// client, and even stream ID for server), to avoid potential
2993 /// collision from peer's instruction. Also we can use
2994 /// `nghttp2_session_set_next_stream_id()` to avoid to open created
2995 /// idle streams accidentally if we follow this recommendation.
2996 ///
2997 /// If |session| is initialized as server, and ``pri_spec->stream_id``
2998 /// points to the idle stream, the idle stream is created if it does
2999 /// not exist. The created idle stream will depend on root stream
3000 /// (stream 0) with weight 16.
3001 ///
3002 /// Otherwise, if stream denoted by ``pri_spec->stream_id`` is not
3003 /// found, we use default priority instead of given |pri_spec|. That
3004 /// is make stream depend on root stream with weight 16.
3005 ///
3006 /// This function returns 0 if it succeeds, or one of the following
3007 /// negative error codes:
3008 ///
3009 /// :enum:`NGHTTP2_ERR_NOMEM`
3010 /// Out of memory.
3011 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3012 /// Attempted to depend on itself; or stream denoted by |stream_id|
3013 /// already exists; or |stream_id| cannot be used to create idle
3014 /// stream (in other words, local endpoint has already opened
3015 /// stream ID greater than or equal to the given stream ID; or
3016 /// |stream_id| is 0
3017 pub fn nghttp2_session_create_idle_stream(
3018 session: *mut nghttp2_session,
3019 stream_id: i32,
3020 pri_spec: *const nghttp2_priority_spec,
3021 ) -> ::std::os::raw::c_int;
3022}
3023extern "C" {
3024 /// @function
3025 ///
3026 /// Performs post-process of HTTP Upgrade request. This function can
3027 /// be called from both client and server, but the behavior is very
3028 /// different in each other.
3029 ///
3030 /// .. warning::
3031 ///
3032 /// This function is deprecated in favor of
3033 /// `nghttp2_session_upgrade2()`, because this function lacks the
3034 /// parameter to tell the library the request method used in the
3035 /// original HTTP request. This information is required for client
3036 /// to validate actual response body length against content-length
3037 /// header field (see `nghttp2_option_set_no_http_messaging()`). If
3038 /// HEAD is used in request, the length of response body must be 0
3039 /// regardless of value included in content-length header field.
3040 ///
3041 /// If called from client side, the |settings_payload| must be the
3042 /// value sent in ``HTTP2-Settings`` header field and must be decoded
3043 /// by base64url decoder. The |settings_payloadlen| is the length of
3044 /// |settings_payload|. The |settings_payload| is unpacked and its
3045 /// setting values will be submitted using `nghttp2_submit_settings()`.
3046 /// This means that the client application code does not need to submit
3047 /// SETTINGS by itself. The stream with stream ID=1 is opened and the
3048 /// |stream_user_data| is used for its stream_user_data. The opened
3049 /// stream becomes half-closed (local) state.
3050 ///
3051 /// If called from server side, the |settings_payload| must be the
3052 /// value received in ``HTTP2-Settings`` header field and must be
3053 /// decoded by base64url decoder. The |settings_payloadlen| is the
3054 /// length of |settings_payload|. It is treated as if the SETTINGS
3055 /// frame with that payload is received. Thus, callback functions for
3056 /// the reception of SETTINGS frame will be invoked. The stream with
3057 /// stream ID=1 is opened. The |stream_user_data| is ignored. The
3058 /// opened stream becomes half-closed (remote).
3059 ///
3060 /// This function returns 0 if it succeeds, or one of the following
3061 /// negative error codes:
3062 ///
3063 /// :enum:`NGHTTP2_ERR_NOMEM`
3064 /// Out of memory.
3065 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3066 /// The |settings_payload| is badly formed.
3067 /// :enum:`NGHTTP2_ERR_PROTO`
3068 /// The stream ID 1 is already used or closed; or is not available.
3069 pub fn nghttp2_session_upgrade(
3070 session: *mut nghttp2_session,
3071 settings_payload: *const u8,
3072 settings_payloadlen: usize,
3073 stream_user_data: *mut ::std::os::raw::c_void,
3074 ) -> ::std::os::raw::c_int;
3075}
3076extern "C" {
3077 /// @function
3078 ///
3079 /// Performs post-process of HTTP Upgrade request. This function can
3080 /// be called from both client and server, but the behavior is very
3081 /// different in each other.
3082 ///
3083 /// If called from client side, the |settings_payload| must be the
3084 /// value sent in ``HTTP2-Settings`` header field and must be decoded
3085 /// by base64url decoder. The |settings_payloadlen| is the length of
3086 /// |settings_payload|. The |settings_payload| is unpacked and its
3087 /// setting values will be submitted using `nghttp2_submit_settings()`.
3088 /// This means that the client application code does not need to submit
3089 /// SETTINGS by itself. The stream with stream ID=1 is opened and the
3090 /// |stream_user_data| is used for its stream_user_data. The opened
3091 /// stream becomes half-closed (local) state.
3092 ///
3093 /// If called from server side, the |settings_payload| must be the
3094 /// value received in ``HTTP2-Settings`` header field and must be
3095 /// decoded by base64url decoder. The |settings_payloadlen| is the
3096 /// length of |settings_payload|. It is treated as if the SETTINGS
3097 /// frame with that payload is received. Thus, callback functions for
3098 /// the reception of SETTINGS frame will be invoked. The stream with
3099 /// stream ID=1 is opened. The |stream_user_data| is ignored. The
3100 /// opened stream becomes half-closed (remote).
3101 ///
3102 /// If the request method is HEAD, pass nonzero value to
3103 /// |head_request|. Otherwise, pass 0.
3104 ///
3105 /// This function returns 0 if it succeeds, or one of the following
3106 /// negative error codes:
3107 ///
3108 /// :enum:`NGHTTP2_ERR_NOMEM`
3109 /// Out of memory.
3110 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3111 /// The |settings_payload| is badly formed.
3112 /// :enum:`NGHTTP2_ERR_PROTO`
3113 /// The stream ID 1 is already used or closed; or is not available.
3114 pub fn nghttp2_session_upgrade2(
3115 session: *mut nghttp2_session,
3116 settings_payload: *const u8,
3117 settings_payloadlen: usize,
3118 head_request: ::std::os::raw::c_int,
3119 stream_user_data: *mut ::std::os::raw::c_void,
3120 ) -> ::std::os::raw::c_int;
3121}
3122extern "C" {
3123 /// @function
3124 ///
3125 /// Serializes the SETTINGS values |iv| in the |buf|. The size of the
3126 /// |buf| is specified by |buflen|. The number of entries in the |iv|
3127 /// array is given by |niv|. The required space in |buf| for the |niv|
3128 /// entries is ``6*niv`` bytes and if the given buffer is too small, an
3129 /// error is returned. This function is used mainly for creating a
3130 /// SETTINGS payload to be sent with the ``HTTP2-Settings`` header
3131 /// field in an HTTP Upgrade request. The data written in |buf| is NOT
3132 /// base64url encoded and the application is responsible for encoding.
3133 ///
3134 /// This function returns the number of bytes written in |buf|, or one
3135 /// of the following negative error codes:
3136 ///
3137 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3138 /// The |iv| contains duplicate settings ID or invalid value.
3139 ///
3140 /// :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`
3141 /// The provided |buflen| size is too small to hold the output.
3142 pub fn nghttp2_pack_settings_payload(
3143 buf: *mut u8,
3144 buflen: usize,
3145 iv: *const nghttp2_settings_entry,
3146 niv: usize,
3147 ) -> isize;
3148}
3149extern "C" {
3150 /// @function
3151 ///
3152 /// Returns string describing the |lib_error_code|. The
3153 /// |lib_error_code| must be one of the :enum:`nghttp2_error`.
3154 pub fn nghttp2_strerror(lib_error_code: ::std::os::raw::c_int)
3155 -> *const ::std::os::raw::c_char;
3156}
3157extern "C" {
3158 /// @function
3159 ///
3160 /// Returns string representation of HTTP/2 error code |error_code|
3161 /// (e.g., ``PROTOCOL_ERROR`` is returned if ``error_code ==
3162 /// NGHTTP2_PROTOCOL_ERROR``). If string representation is unknown for
3163 /// given |error_code|, this function returns string ``unknown``.
3164 pub fn nghttp2_http2_strerror(error_code: u32) -> *const ::std::os::raw::c_char;
3165}
3166extern "C" {
3167 /// @function
3168 ///
3169 /// Initializes |pri_spec| with the |stream_id| of the stream to depend
3170 /// on with |weight| and its exclusive flag. If |exclusive| is
3171 /// nonzero, exclusive flag is set.
3172 ///
3173 /// The |weight| must be in [:enum:`NGHTTP2_MIN_WEIGHT`,
3174 /// :enum:`NGHTTP2_MAX_WEIGHT`], inclusive.
3175 pub fn nghttp2_priority_spec_init(
3176 pri_spec: *mut nghttp2_priority_spec,
3177 stream_id: i32,
3178 weight: i32,
3179 exclusive: ::std::os::raw::c_int,
3180 );
3181}
3182extern "C" {
3183 /// @function
3184 ///
3185 /// Initializes |pri_spec| with the default values. The default values
3186 /// are: stream_id = 0, weight = :macro:`NGHTTP2_DEFAULT_WEIGHT` and
3187 /// exclusive = 0.
3188 pub fn nghttp2_priority_spec_default_init(pri_spec: *mut nghttp2_priority_spec);
3189}
3190extern "C" {
3191 /// @function
3192 ///
3193 /// Returns nonzero if the |pri_spec| is filled with default values.
3194 pub fn nghttp2_priority_spec_check_default(
3195 pri_spec: *const nghttp2_priority_spec,
3196 ) -> ::std::os::raw::c_int;
3197}
3198extern "C" {
3199 /// @function
3200 ///
3201 /// Submits HEADERS frame and optionally one or more DATA frames.
3202 ///
3203 /// The |pri_spec| is priority specification of this request. ``NULL``
3204 /// means the default priority (see
3205 /// `nghttp2_priority_spec_default_init()`). To specify the priority,
3206 /// use `nghttp2_priority_spec_init()`. If |pri_spec| is not ``NULL``,
3207 /// this function will copy its data members.
3208 ///
3209 /// The ``pri_spec->weight`` must be in [:enum:`NGHTTP2_MIN_WEIGHT`,
3210 /// :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` is
3211 /// strictly less than :enum:`NGHTTP2_MIN_WEIGHT`, it becomes
3212 /// :enum:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than
3213 /// :enum:`NGHTTP2_MAX_WEIGHT`, it becomes :enum:`NGHTTP2_MAX_WEIGHT`.
3214 ///
3215 /// The |nva| is an array of name/value pair :type:`nghttp2_nv` with
3216 /// |nvlen| elements. The application is responsible to include
3217 /// required pseudo-header fields (header field whose name starts with
3218 /// ":") in |nva| and must place pseudo-headers before regular header
3219 /// fields.
3220 ///
3221 /// This function creates copies of all name/value pairs in |nva|. It
3222 /// also lower-cases all names in |nva|. The order of elements in
3223 /// |nva| is preserved. For header fields with
3224 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and
3225 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name
3226 /// and value are not copied respectively. With
3227 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to
3228 /// pass header field name in lowercase. The application should
3229 /// maintain the references to them until
3230 /// :type:`nghttp2_on_frame_send_callback` or
3231 /// :type:`nghttp2_on_frame_not_send_callback` is called.
3232 ///
3233 /// HTTP/2 specification has requirement about header fields in the
3234 /// request HEADERS. See the specification for more details.
3235 ///
3236 /// If |data_prd| is not ``NULL``, it provides data which will be sent
3237 /// in subsequent DATA frames. In this case, a method that allows
3238 /// request message bodies
3239 /// (https://tools.ietf.org/html/rfc7231#section-4) must be specified
3240 /// with ``:method`` key in |nva| (e.g. ``POST``). This function does
3241 /// not take ownership of the |data_prd|. The function copies the
3242 /// members of the |data_prd|. If |data_prd| is ``NULL``, HEADERS have
3243 /// END_STREAM set. The |stream_user_data| is data associated to the
3244 /// stream opened by this request and can be an arbitrary pointer,
3245 /// which can be retrieved later by
3246 /// `nghttp2_session_get_stream_user_data()`.
3247 ///
3248 /// This function returns assigned stream ID if it succeeds, or one of
3249 /// the following negative error codes:
3250 ///
3251 /// :enum:`NGHTTP2_ERR_NOMEM`
3252 /// Out of memory.
3253 /// :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE`
3254 /// No stream ID is available because maximum stream ID was
3255 /// reached.
3256 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3257 /// Trying to depend on itself (new stream ID equals
3258 /// ``pri_spec->stream_id``).
3259 /// :enum:`NGHTTP2_ERR_PROTO`
3260 /// The |session| is server session.
3261 ///
3262 /// .. warning::
3263 ///
3264 /// This function returns assigned stream ID if it succeeds. But
3265 /// that stream is not created yet. The application must not submit
3266 /// frame to that stream ID before
3267 /// :type:`nghttp2_before_frame_send_callback` is called for this
3268 /// frame. This means `nghttp2_session_get_stream_user_data()` does
3269 /// not work before the callback. But
3270 /// `nghttp2_session_set_stream_user_data()` handles this situation
3271 /// specially, and it can set data to a stream during this period.
3272 ///
3273 pub fn nghttp2_submit_request(
3274 session: *mut nghttp2_session,
3275 pri_spec: *const nghttp2_priority_spec,
3276 nva: *const nghttp2_nv,
3277 nvlen: usize,
3278 data_prd: *const nghttp2_data_provider,
3279 stream_user_data: *mut ::std::os::raw::c_void,
3280 ) -> i32;
3281}
3282extern "C" {
3283 /// @function
3284 ///
3285 /// Submits response HEADERS frame and optionally one or more DATA
3286 /// frames against the stream |stream_id|.
3287 ///
3288 /// The |nva| is an array of name/value pair :type:`nghttp2_nv` with
3289 /// |nvlen| elements. The application is responsible to include
3290 /// required pseudo-header fields (header field whose name starts with
3291 /// ":") in |nva| and must place pseudo-headers before regular header
3292 /// fields.
3293 ///
3294 /// This function creates copies of all name/value pairs in |nva|. It
3295 /// also lower-cases all names in |nva|. The order of elements in
3296 /// |nva| is preserved. For header fields with
3297 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and
3298 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name
3299 /// and value are not copied respectively. With
3300 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to
3301 /// pass header field name in lowercase. The application should
3302 /// maintain the references to them until
3303 /// :type:`nghttp2_on_frame_send_callback` or
3304 /// :type:`nghttp2_on_frame_not_send_callback` is called.
3305 ///
3306 /// HTTP/2 specification has requirement about header fields in the
3307 /// response HEADERS. See the specification for more details.
3308 ///
3309 /// If |data_prd| is not ``NULL``, it provides data which will be sent
3310 /// in subsequent DATA frames. This function does not take ownership
3311 /// of the |data_prd|. The function copies the members of the
3312 /// |data_prd|. If |data_prd| is ``NULL``, HEADERS will have
3313 /// END_STREAM flag set.
3314 ///
3315 /// This method can be used as normal HTTP response and push response.
3316 /// When pushing a resource using this function, the |session| must be
3317 /// configured using `nghttp2_session_server_new()` or its variants and
3318 /// the target stream denoted by the |stream_id| must be reserved using
3319 /// `nghttp2_submit_push_promise()`.
3320 ///
3321 /// To send non-final response headers (e.g., HTTP status 101), don't
3322 /// use this function because this function half-closes the outbound
3323 /// stream. Instead, use `nghttp2_submit_headers()` for this purpose.
3324 ///
3325 /// This function returns 0 if it succeeds, or one of the following
3326 /// negative error codes:
3327 ///
3328 /// :enum:`NGHTTP2_ERR_NOMEM`
3329 /// Out of memory.
3330 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3331 /// The |stream_id| is 0.
3332 /// :enum:`NGHTTP2_ERR_DATA_EXIST`
3333 /// DATA or HEADERS has been already submitted and not fully
3334 /// processed yet. Normally, this does not happen, but when
3335 /// application wrongly calls `nghttp2_submit_response()` twice,
3336 /// this may happen.
3337 /// :enum:`NGHTTP2_ERR_PROTO`
3338 /// The |session| is client session.
3339 ///
3340 /// .. warning::
3341 ///
3342 /// Calling this function twice for the same stream ID may lead to
3343 /// program crash. It is generally considered to a programming error
3344 /// to commit response twice.
3345 pub fn nghttp2_submit_response(
3346 session: *mut nghttp2_session,
3347 stream_id: i32,
3348 nva: *const nghttp2_nv,
3349 nvlen: usize,
3350 data_prd: *const nghttp2_data_provider,
3351 ) -> ::std::os::raw::c_int;
3352}
3353extern "C" {
3354 /// @function
3355 ///
3356 /// Submits trailer fields HEADERS against the stream |stream_id|.
3357 ///
3358 /// The |nva| is an array of name/value pair :type:`nghttp2_nv` with
3359 /// |nvlen| elements. The application must not include pseudo-header
3360 /// fields (headers whose names starts with ":") in |nva|.
3361 ///
3362 /// This function creates copies of all name/value pairs in |nva|. It
3363 /// also lower-cases all names in |nva|. The order of elements in
3364 /// |nva| is preserved. For header fields with
3365 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and
3366 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name
3367 /// and value are not copied respectively. With
3368 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to
3369 /// pass header field name in lowercase. The application should
3370 /// maintain the references to them until
3371 /// :type:`nghttp2_on_frame_send_callback` or
3372 /// :type:`nghttp2_on_frame_not_send_callback` is called.
3373 ///
3374 /// For server, trailer fields must follow response HEADERS or response
3375 /// DATA without END_STREAM flat set. The library does not enforce
3376 /// this requirement, and applications should do this for themselves.
3377 /// If `nghttp2_submit_trailer()` is called before any response HEADERS
3378 /// submission (usually by `nghttp2_submit_response()`), the content of
3379 /// |nva| will be sent as response headers, which will result in error.
3380 ///
3381 /// This function has the same effect with `nghttp2_submit_headers()`,
3382 /// with flags = :enum:`NGHTTP2_FLAG_END_STREAM` and both pri_spec and
3383 /// stream_user_data to NULL.
3384 ///
3385 /// To submit trailer fields after `nghttp2_submit_response()` is
3386 /// called, the application has to specify
3387 /// :type:`nghttp2_data_provider` to `nghttp2_submit_response()`.
3388 /// Inside of :type:`nghttp2_data_source_read_callback`, when setting
3389 /// :enum:`NGHTTP2_DATA_FLAG_EOF`, also set
3390 /// :enum:`NGHTTP2_DATA_FLAG_NO_END_STREAM`. After that, the
3391 /// application can send trailer fields using
3392 /// `nghttp2_submit_trailer()`. `nghttp2_submit_trailer()` can be used
3393 /// inside :type:`nghttp2_data_source_read_callback`.
3394 ///
3395 /// This function returns 0 if it succeeds and |stream_id| is -1.
3396 /// Otherwise, this function returns 0 if it succeeds, or one of the
3397 /// following negative error codes:
3398 ///
3399 /// :enum:`NGHTTP2_ERR_NOMEM`
3400 /// Out of memory.
3401 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3402 /// The |stream_id| is 0.
3403 pub fn nghttp2_submit_trailer(
3404 session: *mut nghttp2_session,
3405 stream_id: i32,
3406 nva: *const nghttp2_nv,
3407 nvlen: usize,
3408 ) -> ::std::os::raw::c_int;
3409}
3410extern "C" {
3411 /// @function
3412 ///
3413 /// Submits HEADERS frame. The |flags| is bitwise OR of the
3414 /// following values:
3415 ///
3416 /// * :enum:`NGHTTP2_FLAG_END_STREAM`
3417 ///
3418 /// If |flags| includes :enum:`NGHTTP2_FLAG_END_STREAM`, this frame has
3419 /// END_STREAM flag set.
3420 ///
3421 /// The library handles the CONTINUATION frame internally and it
3422 /// correctly sets END_HEADERS to the last sequence of the PUSH_PROMISE
3423 /// or CONTINUATION frame.
3424 ///
3425 /// If the |stream_id| is -1, this frame is assumed as request (i.e.,
3426 /// request HEADERS frame which opens new stream). In this case, the
3427 /// assigned stream ID will be returned. Otherwise, specify stream ID
3428 /// in |stream_id|.
3429 ///
3430 /// The |pri_spec| is priority specification of this request. ``NULL``
3431 /// means the default priority (see
3432 /// `nghttp2_priority_spec_default_init()`). To specify the priority,
3433 /// use `nghttp2_priority_spec_init()`. If |pri_spec| is not ``NULL``,
3434 /// this function will copy its data members.
3435 ///
3436 /// The ``pri_spec->weight`` must be in [:enum:`NGHTTP2_MIN_WEIGHT`,
3437 /// :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` is
3438 /// strictly less than :enum:`NGHTTP2_MIN_WEIGHT`, it becomes
3439 /// :enum:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than
3440 /// :enum:`NGHTTP2_MAX_WEIGHT`, it becomes :enum:`NGHTTP2_MAX_WEIGHT`.
3441 ///
3442 /// The |nva| is an array of name/value pair :type:`nghttp2_nv` with
3443 /// |nvlen| elements. The application is responsible to include
3444 /// required pseudo-header fields (header field whose name starts with
3445 /// ":") in |nva| and must place pseudo-headers before regular header
3446 /// fields.
3447 ///
3448 /// This function creates copies of all name/value pairs in |nva|. It
3449 /// also lower-cases all names in |nva|. The order of elements in
3450 /// |nva| is preserved. For header fields with
3451 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and
3452 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name
3453 /// and value are not copied respectively. With
3454 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to
3455 /// pass header field name in lowercase. The application should
3456 /// maintain the references to them until
3457 /// :type:`nghttp2_on_frame_send_callback` or
3458 /// :type:`nghttp2_on_frame_not_send_callback` is called.
3459 ///
3460 /// The |stream_user_data| is a pointer to an arbitrary data which is
3461 /// associated to the stream this frame will open. Therefore it is
3462 /// only used if this frame opens streams, in other words, it changes
3463 /// stream state from idle or reserved to open.
3464 ///
3465 /// This function is low-level in a sense that the application code can
3466 /// specify flags directly. For usual HTTP request,
3467 /// `nghttp2_submit_request()` is useful. Likewise, for HTTP response,
3468 /// prefer `nghttp2_submit_response()`.
3469 ///
3470 /// This function returns newly assigned stream ID if it succeeds and
3471 /// |stream_id| is -1. Otherwise, this function returns 0 if it
3472 /// succeeds, or one of the following negative error codes:
3473 ///
3474 /// :enum:`NGHTTP2_ERR_NOMEM`
3475 /// Out of memory.
3476 /// :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE`
3477 /// No stream ID is available because maximum stream ID was
3478 /// reached.
3479 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3480 /// The |stream_id| is 0; or trying to depend on itself (stream ID
3481 /// equals ``pri_spec->stream_id``).
3482 /// :enum:`NGHTTP2_ERR_DATA_EXIST`
3483 /// DATA or HEADERS has been already submitted and not fully
3484 /// processed yet. This happens if stream denoted by |stream_id|
3485 /// is in reserved state.
3486 /// :enum:`NGHTTP2_ERR_PROTO`
3487 /// The |stream_id| is -1, and |session| is server session.
3488 ///
3489 /// .. warning::
3490 ///
3491 /// This function returns assigned stream ID if it succeeds and
3492 /// |stream_id| is -1. But that stream is not opened yet. The
3493 /// application must not submit frame to that stream ID before
3494 /// :type:`nghttp2_before_frame_send_callback` is called for this
3495 /// frame.
3496 ///
3497 pub fn nghttp2_submit_headers(
3498 session: *mut nghttp2_session,
3499 flags: u8,
3500 stream_id: i32,
3501 pri_spec: *const nghttp2_priority_spec,
3502 nva: *const nghttp2_nv,
3503 nvlen: usize,
3504 stream_user_data: *mut ::std::os::raw::c_void,
3505 ) -> i32;
3506}
3507extern "C" {
3508 /// @function
3509 ///
3510 /// Submits one or more DATA frames to the stream |stream_id|. The
3511 /// data to be sent are provided by |data_prd|. If |flags| contains
3512 /// :enum:`NGHTTP2_FLAG_END_STREAM`, the last DATA frame has END_STREAM
3513 /// flag set.
3514 ///
3515 /// This function does not take ownership of the |data_prd|. The
3516 /// function copies the members of the |data_prd|.
3517 ///
3518 /// This function returns 0 if it succeeds, or one of the following
3519 /// negative error codes:
3520 ///
3521 /// :enum:`NGHTTP2_ERR_NOMEM`
3522 /// Out of memory.
3523 /// :enum:`NGHTTP2_ERR_DATA_EXIST`
3524 /// DATA or HEADERS has been already submitted and not fully
3525 /// processed yet.
3526 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3527 /// The |stream_id| is 0.
3528 /// :enum:`NGHTTP2_ERR_STREAM_CLOSED`
3529 /// The stream was already closed; or the |stream_id| is invalid.
3530 ///
3531 /// .. note::
3532 ///
3533 /// Currently, only one DATA or HEADERS is allowed for a stream at a
3534 /// time. Submitting these frames more than once before first DATA
3535 /// or HEADERS is finished results in :enum:`NGHTTP2_ERR_DATA_EXIST`
3536 /// error code. The earliest callback which tells that previous
3537 /// frame is done is :type:`nghttp2_on_frame_send_callback`. In side
3538 /// that callback, new data can be submitted using
3539 /// `nghttp2_submit_data()`. Of course, all data except for last one
3540 /// must not have :enum:`NGHTTP2_FLAG_END_STREAM` flag set in
3541 /// |flags|. This sounds a bit complicated, and we recommend to use
3542 /// `nghttp2_submit_request()` and `nghttp2_submit_response()` to
3543 /// avoid this cascading issue. The experience shows that for HTTP
3544 /// use, these two functions are enough to implement both client and
3545 /// server.
3546 pub fn nghttp2_submit_data(
3547 session: *mut nghttp2_session,
3548 flags: u8,
3549 stream_id: i32,
3550 data_prd: *const nghttp2_data_provider,
3551 ) -> ::std::os::raw::c_int;
3552}
3553extern "C" {
3554 /// @function
3555 ///
3556 /// Submits PRIORITY frame to change the priority of stream |stream_id|
3557 /// to the priority specification |pri_spec|.
3558 ///
3559 /// The |flags| is currently ignored and should be
3560 /// :enum:`NGHTTP2_FLAG_NONE`.
3561 ///
3562 /// The |pri_spec| is priority specification of this request. ``NULL``
3563 /// is not allowed for this function. To specify the priority, use
3564 /// `nghttp2_priority_spec_init()`. This function will copy its data
3565 /// members.
3566 ///
3567 /// The ``pri_spec->weight`` must be in [:enum:`NGHTTP2_MIN_WEIGHT`,
3568 /// :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` is
3569 /// strictly less than :enum:`NGHTTP2_MIN_WEIGHT`, it becomes
3570 /// :enum:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than
3571 /// :enum:`NGHTTP2_MAX_WEIGHT`, it becomes :enum:`NGHTTP2_MAX_WEIGHT`.
3572 ///
3573 /// This function returns 0 if it succeeds, or one of the following
3574 /// negative error codes:
3575 ///
3576 /// :enum:`NGHTTP2_ERR_NOMEM`
3577 /// Out of memory.
3578 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3579 /// The |stream_id| is 0; or the |pri_spec| is NULL; or trying to
3580 /// depend on itself.
3581 pub fn nghttp2_submit_priority(
3582 session: *mut nghttp2_session,
3583 flags: u8,
3584 stream_id: i32,
3585 pri_spec: *const nghttp2_priority_spec,
3586 ) -> ::std::os::raw::c_int;
3587}
3588extern "C" {
3589 /// @function
3590 ///
3591 /// Submits RST_STREAM frame to cancel/reject the stream |stream_id|
3592 /// with the error code |error_code|.
3593 ///
3594 /// The pre-defined error code is one of :enum:`nghttp2_error_code`.
3595 ///
3596 /// The |flags| is currently ignored and should be
3597 /// :enum:`NGHTTP2_FLAG_NONE`.
3598 ///
3599 /// This function returns 0 if it succeeds, or one of the following
3600 /// negative error codes:
3601 ///
3602 /// :enum:`NGHTTP2_ERR_NOMEM`
3603 /// Out of memory.
3604 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3605 /// The |stream_id| is 0.
3606 pub fn nghttp2_submit_rst_stream(
3607 session: *mut nghttp2_session,
3608 flags: u8,
3609 stream_id: i32,
3610 error_code: u32,
3611 ) -> ::std::os::raw::c_int;
3612}
3613extern "C" {
3614 /// @function
3615 ///
3616 /// Stores local settings and submits SETTINGS frame. The |iv| is the
3617 /// pointer to the array of :type:`nghttp2_settings_entry`. The |niv|
3618 /// indicates the number of :type:`nghttp2_settings_entry`.
3619 ///
3620 /// The |flags| is currently ignored and should be
3621 /// :enum:`NGHTTP2_FLAG_NONE`.
3622 ///
3623 /// This function does not take ownership of the |iv|. This function
3624 /// copies all the elements in the |iv|.
3625 ///
3626 /// While updating individual stream's local window size, if the window
3627 /// size becomes strictly larger than NGHTTP2_MAX_WINDOW_SIZE,
3628 /// RST_STREAM is issued against such a stream.
3629 ///
3630 /// SETTINGS with :enum:`NGHTTP2_FLAG_ACK` is automatically submitted
3631 /// by the library and application could not send it at its will.
3632 ///
3633 /// This function returns 0 if it succeeds, or one of the following
3634 /// negative error codes:
3635 ///
3636 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3637 /// The |iv| contains invalid value (e.g., initial window size
3638 /// strictly greater than (1 << 31) - 1.
3639 /// :enum:`NGHTTP2_ERR_NOMEM`
3640 /// Out of memory.
3641 pub fn nghttp2_submit_settings(
3642 session: *mut nghttp2_session,
3643 flags: u8,
3644 iv: *const nghttp2_settings_entry,
3645 niv: usize,
3646 ) -> ::std::os::raw::c_int;
3647}
3648extern "C" {
3649 /// @function
3650 ///
3651 /// Submits PUSH_PROMISE frame.
3652 ///
3653 /// The |flags| is currently ignored. The library handles the
3654 /// CONTINUATION frame internally and it correctly sets END_HEADERS to
3655 /// the last sequence of the PUSH_PROMISE or CONTINUATION frame.
3656 ///
3657 /// The |stream_id| must be client initiated stream ID.
3658 ///
3659 /// The |nva| is an array of name/value pair :type:`nghttp2_nv` with
3660 /// |nvlen| elements. The application is responsible to include
3661 /// required pseudo-header fields (header field whose name starts with
3662 /// ":") in |nva| and must place pseudo-headers before regular header
3663 /// fields.
3664 ///
3665 /// This function creates copies of all name/value pairs in |nva|. It
3666 /// also lower-cases all names in |nva|. The order of elements in
3667 /// |nva| is preserved. For header fields with
3668 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and
3669 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name
3670 /// and value are not copied respectively. With
3671 /// :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to
3672 /// pass header field name in lowercase. The application should
3673 /// maintain the references to them until
3674 /// :type:`nghttp2_on_frame_send_callback` or
3675 /// :type:`nghttp2_on_frame_not_send_callback` is called.
3676 ///
3677 /// The |promised_stream_user_data| is a pointer to an arbitrary data
3678 /// which is associated to the promised stream this frame will open and
3679 /// make it in reserved state. It is available using
3680 /// `nghttp2_session_get_stream_user_data()`. The application can
3681 /// access it in :type:`nghttp2_before_frame_send_callback` and
3682 /// :type:`nghttp2_on_frame_send_callback` of this frame.
3683 ///
3684 /// The client side is not allowed to use this function.
3685 ///
3686 /// To submit response headers and data, use
3687 /// `nghttp2_submit_response()`.
3688 ///
3689 /// This function returns assigned promised stream ID if it succeeds,
3690 /// or one of the following negative error codes:
3691 ///
3692 /// :enum:`NGHTTP2_ERR_NOMEM`
3693 /// Out of memory.
3694 /// :enum:`NGHTTP2_ERR_PROTO`
3695 /// This function was invoked when |session| is initialized as
3696 /// client.
3697 /// :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE`
3698 /// No stream ID is available because maximum stream ID was
3699 /// reached.
3700 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3701 /// The |stream_id| is 0; The |stream_id| does not designate stream
3702 /// that peer initiated.
3703 /// :enum:`NGHTTP2_ERR_STREAM_CLOSED`
3704 /// The stream was already closed; or the |stream_id| is invalid.
3705 ///
3706 /// .. warning::
3707 ///
3708 /// This function returns assigned promised stream ID if it succeeds.
3709 /// As of 1.16.0, stream object for pushed resource is created when
3710 /// this function succeeds. In that case, the application can submit
3711 /// push response for the promised frame.
3712 ///
3713 /// In 1.15.0 or prior versions, pushed stream is not opened yet when
3714 /// this function succeeds. The application must not submit frame to
3715 /// that stream ID before :type:`nghttp2_before_frame_send_callback`
3716 /// is called for this frame.
3717 ///
3718 pub fn nghttp2_submit_push_promise(
3719 session: *mut nghttp2_session,
3720 flags: u8,
3721 stream_id: i32,
3722 nva: *const nghttp2_nv,
3723 nvlen: usize,
3724 promised_stream_user_data: *mut ::std::os::raw::c_void,
3725 ) -> i32;
3726}
3727extern "C" {
3728 /// @function
3729 ///
3730 /// Submits PING frame. You don't have to send PING back when you
3731 /// received PING frame. The library automatically submits PING frame
3732 /// in this case.
3733 ///
3734 /// The |flags| is bitwise OR of 0 or more of the following value.
3735 ///
3736 /// * :enum:`NGHTTP2_FLAG_ACK`
3737 ///
3738 /// Unless `nghttp2_option_set_no_auto_ping_ack()` is used, the |flags|
3739 /// should be :enum:`NGHTTP2_FLAG_NONE`.
3740 ///
3741 /// If the |opaque_data| is non ``NULL``, then it should point to the 8
3742 /// bytes array of memory to specify opaque data to send with PING
3743 /// frame. If the |opaque_data| is ``NULL``, zero-cleared 8 bytes will
3744 /// be sent as opaque data.
3745 ///
3746 /// This function returns 0 if it succeeds, or one of the following
3747 /// negative error codes:
3748 ///
3749 /// :enum:`NGHTTP2_ERR_NOMEM`
3750 /// Out of memory.
3751 pub fn nghttp2_submit_ping(
3752 session: *mut nghttp2_session,
3753 flags: u8,
3754 opaque_data: *const u8,
3755 ) -> ::std::os::raw::c_int;
3756}
3757extern "C" {
3758 /// @function
3759 ///
3760 /// Submits GOAWAY frame with the last stream ID |last_stream_id| and
3761 /// the error code |error_code|.
3762 ///
3763 /// The pre-defined error code is one of :enum:`nghttp2_error_code`.
3764 ///
3765 /// The |flags| is currently ignored and should be
3766 /// :enum:`NGHTTP2_FLAG_NONE`.
3767 ///
3768 /// The |last_stream_id| is peer's stream ID or 0. So if |session| is
3769 /// initialized as client, |last_stream_id| must be even or 0. If
3770 /// |session| is initialized as server, |last_stream_id| must be odd or
3771 /// 0.
3772 ///
3773 /// The HTTP/2 specification says last_stream_id must not be increased
3774 /// from the value previously sent. So the actual value sent as
3775 /// last_stream_id is the minimum value between the given
3776 /// |last_stream_id| and the last_stream_id previously sent to the
3777 /// peer.
3778 ///
3779 /// If the |opaque_data| is not ``NULL`` and |opaque_data_len| is not
3780 /// zero, those data will be sent as additional debug data. The
3781 /// library makes a copy of the memory region pointed by |opaque_data|
3782 /// with the length |opaque_data_len|, so the caller does not need to
3783 /// keep this memory after the return of this function. If the
3784 /// |opaque_data_len| is 0, the |opaque_data| could be ``NULL``.
3785 ///
3786 /// After successful transmission of GOAWAY, following things happen.
3787 /// All incoming streams having strictly more than |last_stream_id| are
3788 /// closed. All incoming HEADERS which starts new stream are simply
3789 /// ignored. After all active streams are handled, both
3790 /// `nghttp2_session_want_read()` and `nghttp2_session_want_write()`
3791 /// return 0 and the application can close session.
3792 ///
3793 /// This function returns 0 if it succeeds, or one of the following
3794 /// negative error codes:
3795 ///
3796 /// :enum:`NGHTTP2_ERR_NOMEM`
3797 /// Out of memory.
3798 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3799 /// The |opaque_data_len| is too large; the |last_stream_id| is
3800 /// invalid.
3801 pub fn nghttp2_submit_goaway(
3802 session: *mut nghttp2_session,
3803 flags: u8,
3804 last_stream_id: i32,
3805 error_code: u32,
3806 opaque_data: *const u8,
3807 opaque_data_len: usize,
3808 ) -> ::std::os::raw::c_int;
3809}
3810extern "C" {
3811 /// @function
3812 ///
3813 /// Returns the last stream ID of a stream for which
3814 /// :type:`nghttp2_on_frame_recv_callback` was invoked most recently.
3815 /// The returned value can be used as last_stream_id parameter for
3816 /// `nghttp2_submit_goaway()` and
3817 /// `nghttp2_session_terminate_session2()`.
3818 ///
3819 /// This function always succeeds.
3820 pub fn nghttp2_session_get_last_proc_stream_id(session: *mut nghttp2_session) -> i32;
3821}
3822extern "C" {
3823 /// @function
3824 ///
3825 /// Returns nonzero if new request can be sent from local endpoint.
3826 ///
3827 /// This function return 0 if request is not allowed for this session.
3828 /// There are several reasons why request is not allowed. Some of the
3829 /// reasons are: session is server; stream ID has been spent; GOAWAY
3830 /// has been sent or received.
3831 ///
3832 /// The application can call `nghttp2_submit_request()` without
3833 /// consulting this function. In that case, `nghttp2_submit_request()`
3834 /// may return error. Or, request is failed to sent, and
3835 /// :type:`nghttp2_on_stream_close_callback` is called.
3836 pub fn nghttp2_session_check_request_allowed(
3837 session: *mut nghttp2_session,
3838 ) -> ::std::os::raw::c_int;
3839}
3840extern "C" {
3841 /// @function
3842 ///
3843 /// Returns nonzero if |session| is initialized as server side session.
3844 pub fn nghttp2_session_check_server_session(
3845 session: *mut nghttp2_session,
3846 ) -> ::std::os::raw::c_int;
3847}
3848extern "C" {
3849 /// @function
3850 ///
3851 /// Submits WINDOW_UPDATE frame.
3852 ///
3853 /// The |flags| is currently ignored and should be
3854 /// :enum:`NGHTTP2_FLAG_NONE`.
3855 ///
3856 /// The |stream_id| is the stream ID to send this WINDOW_UPDATE. To
3857 /// send connection level WINDOW_UPDATE, specify 0 to |stream_id|.
3858 ///
3859 /// If the |window_size_increment| is positive, the WINDOW_UPDATE with
3860 /// that value as window_size_increment is queued. If the
3861 /// |window_size_increment| is larger than the received bytes from the
3862 /// remote endpoint, the local window size is increased by that
3863 /// difference. If the sole purpose is to increase the local window
3864 /// size, consider to use `nghttp2_session_set_local_window_size()`.
3865 ///
3866 /// If the |window_size_increment| is negative, the local window size
3867 /// is decreased by -|window_size_increment|. If automatic
3868 /// WINDOW_UPDATE is enabled
3869 /// (`nghttp2_option_set_no_auto_window_update()`), and the library
3870 /// decided that the WINDOW_UPDATE should be submitted, then
3871 /// WINDOW_UPDATE is queued with the current received bytes count. If
3872 /// the sole purpose is to decrease the local window size, consider to
3873 /// use `nghttp2_session_set_local_window_size()`.
3874 ///
3875 /// If the |window_size_increment| is 0, the function does nothing and
3876 /// returns 0.
3877 ///
3878 /// This function returns 0 if it succeeds, or one of the following
3879 /// negative error codes:
3880 ///
3881 /// :enum:`NGHTTP2_ERR_FLOW_CONTROL`
3882 /// The local window size overflow or gets negative.
3883 /// :enum:`NGHTTP2_ERR_NOMEM`
3884 /// Out of memory.
3885 pub fn nghttp2_submit_window_update(
3886 session: *mut nghttp2_session,
3887 flags: u8,
3888 stream_id: i32,
3889 window_size_increment: i32,
3890 ) -> ::std::os::raw::c_int;
3891}
3892extern "C" {
3893 /// @function
3894 ///
3895 /// Set local window size (local endpoints's window size) to the given
3896 /// |window_size| for the given stream denoted by |stream_id|. To
3897 /// change connection level window size, specify 0 to |stream_id|. To
3898 /// increase window size, this function may submit WINDOW_UPDATE frame
3899 /// to transmission queue.
3900 ///
3901 /// The |flags| is currently ignored and should be
3902 /// :enum:`NGHTTP2_FLAG_NONE`.
3903 ///
3904 /// This sounds similar to `nghttp2_submit_window_update()`, but there
3905 /// are 2 differences. The first difference is that this function
3906 /// takes the absolute value of window size to set, rather than the
3907 /// delta. To change the window size, this may be easier to use since
3908 /// the application just declares the intended window size, rather than
3909 /// calculating delta. The second difference is that
3910 /// `nghttp2_submit_window_update()` affects the received bytes count
3911 /// which has not acked yet. By the specification of
3912 /// `nghttp2_submit_window_update()`, to strictly increase the local
3913 /// window size, we have to submit delta including all received bytes
3914 /// count, which might not be desirable in some cases. On the other
3915 /// hand, this function does not affect the received bytes count. It
3916 /// just sets the local window size to the given value.
3917 ///
3918 /// This function returns 0 if it succeeds, or one of the following
3919 /// negative error codes:
3920 ///
3921 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3922 /// The |stream_id| is negative.
3923 /// :enum:`NGHTTP2_ERR_NOMEM`
3924 /// Out of memory.
3925 pub fn nghttp2_session_set_local_window_size(
3926 session: *mut nghttp2_session,
3927 flags: u8,
3928 stream_id: i32,
3929 window_size: i32,
3930 ) -> ::std::os::raw::c_int;
3931}
3932extern "C" {
3933 /// @function
3934 ///
3935 /// Submits extension frame.
3936 ///
3937 /// Application can pass arbitrary frame flags and stream ID in |flags|
3938 /// and |stream_id| respectively. The |payload| is opaque pointer, and
3939 /// it can be accessible though ``frame->ext.payload`` in
3940 /// :type:`nghttp2_pack_extension_callback`. The library will not own
3941 /// passed |payload| pointer.
3942 ///
3943 /// The application must set :type:`nghttp2_pack_extension_callback`
3944 /// using `nghttp2_session_callbacks_set_pack_extension_callback()`.
3945 ///
3946 /// The application should retain the memory pointed by |payload| until
3947 /// the transmission of extension frame is done (which is indicated by
3948 /// :type:`nghttp2_on_frame_send_callback`), or transmission fails
3949 /// (which is indicated by :type:`nghttp2_on_frame_not_send_callback`).
3950 /// If application does not touch this memory region after packing it
3951 /// into a wire format, application can free it inside
3952 /// :type:`nghttp2_pack_extension_callback`.
3953 ///
3954 /// The standard HTTP/2 frame cannot be sent with this function, so
3955 /// |type| must be strictly grater than 0x9. Otherwise, this function
3956 /// will fail with error code :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`.
3957 ///
3958 /// This function returns 0 if it succeeds, or one of the following
3959 /// negative error codes:
3960 ///
3961 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
3962 /// If :type:`nghttp2_pack_extension_callback` is not set.
3963 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
3964 /// If |type| specifies standard HTTP/2 frame type. The frame
3965 /// types in the rage [0x0, 0x9], both inclusive, are standard
3966 /// HTTP/2 frame type, and cannot be sent using this function.
3967 /// :enum:`NGHTTP2_ERR_NOMEM`
3968 /// Out of memory
3969 pub fn nghttp2_submit_extension(
3970 session: *mut nghttp2_session,
3971 type_: u8,
3972 flags: u8,
3973 stream_id: i32,
3974 payload: *mut ::std::os::raw::c_void,
3975 ) -> ::std::os::raw::c_int;
3976}
3977/// @struct
3978///
3979/// The payload of ALTSVC frame. ALTSVC frame is a non-critical
3980/// extension to HTTP/2. If this frame is received, and
3981/// `nghttp2_option_set_user_recv_extension_type()` is not set, and
3982/// `nghttp2_option_set_builtin_recv_extension_type()` is set for
3983/// :enum:`NGHTTP2_ALTSVC`, ``nghttp2_extension.payload`` will point to
3984/// this struct.
3985///
3986/// It has the following members:
3987#[repr(C)]
3988#[derive(Debug, Copy, Clone)]
3989pub struct nghttp2_ext_altsvc {
3990 /// The pointer to origin which this alternative service is
3991 /// associated with. This is not necessarily NULL-terminated.
3992 pub origin: *mut u8,
3993 /// The length of the |origin|.
3994 pub origin_len: usize,
3995 /// The pointer to Alt-Svc field value contained in ALTSVC frame.
3996 /// This is not necessarily NULL-terminated.
3997 pub field_value: *mut u8,
3998 /// The length of the |field_value|.
3999 pub field_value_len: usize,
4000}
4001extern "C" {
4002 /// @function
4003 ///
4004 /// Submits ALTSVC frame.
4005 ///
4006 /// ALTSVC frame is a non-critical extension to HTTP/2, and defined in
4007 /// `RFC 7383 <https://tools.ietf.org/html/rfc7838#section-4>`_.
4008 ///
4009 /// The |flags| is currently ignored and should be
4010 /// :enum:`NGHTTP2_FLAG_NONE`.
4011 ///
4012 /// The |origin| points to the origin this alternative service is
4013 /// associated with. The |origin_len| is the length of the origin. If
4014 /// |stream_id| is 0, the origin must be specified. If |stream_id| is
4015 /// not zero, the origin must be empty (in other words, |origin_len|
4016 /// must be 0).
4017 ///
4018 /// The ALTSVC frame is only usable from server side. If this function
4019 /// is invoked with client side session, this function returns
4020 /// :enum:`NGHTTP2_ERR_INVALID_STATE`.
4021 ///
4022 /// This function returns 0 if it succeeds, or one of the following
4023 /// negative error codes:
4024 ///
4025 /// :enum:`NGHTTP2_ERR_NOMEM`
4026 /// Out of memory
4027 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
4028 /// The function is called from client side session
4029 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
4030 /// The sum of |origin_len| and |field_value_len| is larger than
4031 /// 16382; or |origin_len| is 0 while |stream_id| is 0; or
4032 /// |origin_len| is not 0 while |stream_id| is not 0.
4033 pub fn nghttp2_submit_altsvc(
4034 session: *mut nghttp2_session,
4035 flags: u8,
4036 stream_id: i32,
4037 origin: *const u8,
4038 origin_len: usize,
4039 field_value: *const u8,
4040 field_value_len: usize,
4041 ) -> ::std::os::raw::c_int;
4042}
4043/// @struct
4044///
4045/// The single entry of an origin.
4046#[repr(C)]
4047#[derive(Debug, Copy, Clone)]
4048pub struct nghttp2_origin_entry {
4049 /// The pointer to origin. No validation is made against this field
4050 /// by the library. This is not necessarily NULL-terminated.
4051 pub origin: *mut u8,
4052 /// The length of the |origin|.
4053 pub origin_len: usize,
4054}
4055/// @struct
4056///
4057/// The payload of ORIGIN frame. ORIGIN frame is a non-critical
4058/// extension to HTTP/2 and defined by `RFC 8336
4059/// <https://tools.ietf.org/html/rfc8336>`_.
4060///
4061/// If this frame is received, and
4062/// `nghttp2_option_set_user_recv_extension_type()` is not set, and
4063/// `nghttp2_option_set_builtin_recv_extension_type()` is set for
4064/// :enum:`NGHTTP2_ORIGIN`, ``nghttp2_extension.payload`` will point to
4065/// this struct.
4066///
4067/// It has the following members:
4068#[repr(C)]
4069#[derive(Debug, Copy, Clone)]
4070pub struct nghttp2_ext_origin {
4071 /// The number of origins contained in |ov|.
4072 pub nov: usize,
4073 /// The pointer to the array of origins contained in ORIGIN frame.
4074 pub ov: *mut nghttp2_origin_entry,
4075}
4076extern "C" {
4077 /// @function
4078 ///
4079 /// Submits ORIGIN frame.
4080 ///
4081 /// ORIGIN frame is a non-critical extension to HTTP/2 and defined by
4082 /// `RFC 8336 <https://tools.ietf.org/html/rfc8336>`_.
4083 ///
4084 /// The |flags| is currently ignored and should be
4085 /// :enum:`NGHTTP2_FLAG_NONE`.
4086 ///
4087 /// The |ov| points to the array of origins. The |nov| specifies the
4088 /// number of origins included in |ov|. This function creates copies
4089 /// of all elements in |ov|.
4090 ///
4091 /// The ORIGIN frame is only usable by a server. If this function is
4092 /// invoked with client side session, this function returns
4093 /// :enum:`NGHTTP2_ERR_INVALID_STATE`.
4094 ///
4095 /// :enum:`NGHTTP2_ERR_NOMEM`
4096 /// Out of memory
4097 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
4098 /// The function is called from client side session.
4099 /// :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
4100 /// There are too many origins, or an origin is too large to fit
4101 /// into a default frame payload.
4102 pub fn nghttp2_submit_origin(
4103 session: *mut nghttp2_session,
4104 flags: u8,
4105 ov: *const nghttp2_origin_entry,
4106 nov: usize,
4107 ) -> ::std::os::raw::c_int;
4108}
4109extern "C" {
4110 /// @function
4111 ///
4112 /// Compares ``lhs->name`` of length ``lhs->namelen`` bytes and
4113 /// ``rhs->name`` of length ``rhs->namelen`` bytes. Returns negative
4114 /// integer if ``lhs->name`` is found to be less than ``rhs->name``; or
4115 /// returns positive integer if ``lhs->name`` is found to be greater
4116 /// than ``rhs->name``; or returns 0 otherwise.
4117 pub fn nghttp2_nv_compare_name(
4118 lhs: *const nghttp2_nv,
4119 rhs: *const nghttp2_nv,
4120 ) -> ::std::os::raw::c_int;
4121}
4122extern "C" {
4123 /// @function
4124 ///
4125 /// A helper function for dealing with NPN in client side or ALPN in
4126 /// server side. The |in| contains peer's protocol list in preferable
4127 /// order. The format of |in| is length-prefixed and not
4128 /// null-terminated. For example, ``h2`` and
4129 /// ``http/1.1`` stored in |in| like this::
4130 ///
4131 /// in[0] = 2
4132 /// in[1..2] = "h2"
4133 /// in[3] = 8
4134 /// in[4..11] = "http/1.1"
4135 /// inlen = 12
4136 ///
4137 /// The selection algorithm is as follows:
4138 ///
4139 /// 1. If peer's list contains HTTP/2 protocol the library supports,
4140 /// it is selected and returns 1. The following step is not taken.
4141 ///
4142 /// 2. If peer's list contains ``http/1.1``, this function selects
4143 /// ``http/1.1`` and returns 0. The following step is not taken.
4144 ///
4145 /// 3. This function selects nothing and returns -1 (So called
4146 /// non-overlap case). In this case, |out| and |outlen| are left
4147 /// untouched.
4148 ///
4149 /// Selecting ``h2`` means that ``h2`` is written into |*out| and its
4150 /// length (which is 2) is assigned to |*outlen|.
4151 ///
4152 /// For ALPN, refer to https://tools.ietf.org/html/rfc7301
4153 ///
4154 /// See http://technotes.googlecode.com/git/nextprotoneg.html for more
4155 /// details about NPN.
4156 ///
4157 /// For NPN, to use this method you should do something like::
4158 ///
4159 /// static int select_next_proto_cb(SSL* ssl,
4160 /// unsigned char **out,
4161 /// unsigned char *outlen,
4162 /// const unsigned char *in,
4163 /// unsigned int inlen,
4164 /// void *arg)
4165 /// {
4166 /// int rv;
4167 /// rv = nghttp2_select_next_protocol(out, outlen, in, inlen);
4168 /// if (rv == -1) {
4169 /// return SSL_TLSEXT_ERR_NOACK;
4170 /// }
4171 /// if (rv == 1) {
4172 /// ((MyType*)arg)->http2_selected = 1;
4173 /// }
4174 /// return SSL_TLSEXT_ERR_OK;
4175 /// }
4176 /// ...
4177 /// SSL_CTX_set_next_proto_select_cb(ssl_ctx, select_next_proto_cb, my_obj);
4178 ///
4179 pub fn nghttp2_select_next_protocol(
4180 out: *mut *mut ::std::os::raw::c_uchar,
4181 outlen: *mut ::std::os::raw::c_uchar,
4182 in_: *const ::std::os::raw::c_uchar,
4183 inlen: ::std::os::raw::c_uint,
4184 ) -> ::std::os::raw::c_int;
4185}
4186extern "C" {
4187 /// @function
4188 ///
4189 /// Returns a pointer to a nghttp2_info struct with version information
4190 /// about the run-time library in use. The |least_version| argument
4191 /// can be set to a 24 bit numerical value for the least accepted
4192 /// version number and if the condition is not met, this function will
4193 /// return a ``NULL``. Pass in 0 to skip the version checking.
4194 pub fn nghttp2_version(least_version: ::std::os::raw::c_int) -> *mut nghttp2_info;
4195}
4196extern "C" {
4197 /// @function
4198 ///
4199 /// Returns nonzero if the :type:`nghttp2_error` library error code
4200 /// |lib_error| is fatal.
4201 pub fn nghttp2_is_fatal(lib_error_code: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
4202}
4203extern "C" {
4204 /// @function
4205 ///
4206 /// Returns nonzero if HTTP header field name |name| of length |len| is
4207 /// valid according to http://tools.ietf.org/html/rfc7230#section-3.2
4208 ///
4209 /// Because this is a header field name in HTTP2, the upper cased alphabet
4210 /// is treated as error.
4211 pub fn nghttp2_check_header_name(name: *const u8, len: usize) -> ::std::os::raw::c_int;
4212}
4213extern "C" {
4214 /// @function
4215 ///
4216 /// Returns nonzero if HTTP header field value |value| of length |len|
4217 /// is valid according to
4218 /// http://tools.ietf.org/html/rfc7230#section-3.2
4219 pub fn nghttp2_check_header_value(value: *const u8, len: usize) -> ::std::os::raw::c_int;
4220}
4221#[repr(C)]
4222#[derive(Debug, Copy, Clone)]
4223pub struct nghttp2_hd_deflater {
4224 _unused: [u8; 0],
4225}
4226extern "C" {
4227 /// @function
4228 ///
4229 /// Initializes |*deflater_ptr| for deflating name/values pairs.
4230 ///
4231 /// The |max_deflate_dynamic_table_size| is the upper bound of header
4232 /// table size the deflater will use.
4233 ///
4234 /// If this function fails, |*deflater_ptr| is left untouched.
4235 ///
4236 /// This function returns 0 if it succeeds, or one of the following
4237 /// negative error codes:
4238 ///
4239 /// :enum:`NGHTTP2_ERR_NOMEM`
4240 /// Out of memory.
4241 pub fn nghttp2_hd_deflate_new(
4242 deflater_ptr: *mut *mut nghttp2_hd_deflater,
4243 max_deflate_dynamic_table_size: usize,
4244 ) -> ::std::os::raw::c_int;
4245}
4246extern "C" {
4247 /// @function
4248 ///
4249 /// Like `nghttp2_hd_deflate_new()`, but with additional custom memory
4250 /// allocator specified in the |mem|.
4251 ///
4252 /// The |mem| can be ``NULL`` and the call is equivalent to
4253 /// `nghttp2_hd_deflate_new()`.
4254 ///
4255 /// This function does not take ownership |mem|. The application is
4256 /// responsible for freeing |mem|.
4257 ///
4258 /// The library code does not refer to |mem| pointer after this
4259 /// function returns, so the application can safely free it.
4260 pub fn nghttp2_hd_deflate_new2(
4261 deflater_ptr: *mut *mut nghttp2_hd_deflater,
4262 max_deflate_dynamic_table_size: usize,
4263 mem: *mut nghttp2_mem,
4264 ) -> ::std::os::raw::c_int;
4265}
4266extern "C" {
4267 /// @function
4268 ///
4269 /// Deallocates any resources allocated for |deflater|.
4270 pub fn nghttp2_hd_deflate_del(deflater: *mut nghttp2_hd_deflater);
4271}
4272extern "C" {
4273 /// @function
4274 ///
4275 /// Changes header table size of the |deflater| to
4276 /// |settings_max_dynamic_table_size| bytes. This may trigger eviction
4277 /// in the dynamic table.
4278 ///
4279 /// The |settings_max_dynamic_table_size| should be the value received
4280 /// in SETTINGS_HEADER_TABLE_SIZE.
4281 ///
4282 /// The deflater never uses more memory than
4283 /// ``max_deflate_dynamic_table_size`` bytes specified in
4284 /// `nghttp2_hd_deflate_new()`. Therefore, if
4285 /// |settings_max_dynamic_table_size| >
4286 /// ``max_deflate_dynamic_table_size``, resulting maximum table size
4287 /// becomes ``max_deflate_dynamic_table_size``.
4288 ///
4289 /// This function returns 0 if it succeeds, or one of the following
4290 /// negative error codes:
4291 ///
4292 /// :enum:`NGHTTP2_ERR_NOMEM`
4293 /// Out of memory.
4294 pub fn nghttp2_hd_deflate_change_table_size(
4295 deflater: *mut nghttp2_hd_deflater,
4296 settings_max_dynamic_table_size: usize,
4297 ) -> ::std::os::raw::c_int;
4298}
4299extern "C" {
4300 /// @function
4301 ///
4302 /// Deflates the |nva|, which has the |nvlen| name/value pairs, into
4303 /// the |buf| of length |buflen|.
4304 ///
4305 /// If |buf| is not large enough to store the deflated header block,
4306 /// this function fails with :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`. The
4307 /// caller should use `nghttp2_hd_deflate_bound()` to know the upper
4308 /// bound of buffer size required to deflate given header name/value
4309 /// pairs.
4310 ///
4311 /// Once this function fails, subsequent call of this function always
4312 /// returns :enum:`NGHTTP2_ERR_HEADER_COMP`.
4313 ///
4314 /// After this function returns, it is safe to delete the |nva|.
4315 ///
4316 /// This function returns the number of bytes written to |buf| if it
4317 /// succeeds, or one of the following negative error codes:
4318 ///
4319 /// :enum:`NGHTTP2_ERR_NOMEM`
4320 /// Out of memory.
4321 /// :enum:`NGHTTP2_ERR_HEADER_COMP`
4322 /// Deflation process has failed.
4323 /// :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`
4324 /// The provided |buflen| size is too small to hold the output.
4325 pub fn nghttp2_hd_deflate_hd(
4326 deflater: *mut nghttp2_hd_deflater,
4327 buf: *mut u8,
4328 buflen: usize,
4329 nva: *const nghttp2_nv,
4330 nvlen: usize,
4331 ) -> isize;
4332}
4333extern "C" {
4334 /// @function
4335 ///
4336 /// Deflates the |nva|, which has the |nvlen| name/value pairs, into
4337 /// the |veclen| size of buf vector |vec|. The each size of buffer
4338 /// must be set in len field of :type:`nghttp2_vec`. If and only if
4339 /// one chunk is filled up completely, next chunk will be used. If
4340 /// |vec| is not large enough to store the deflated header block, this
4341 /// function fails with :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller
4342 /// should use `nghttp2_hd_deflate_bound()` to know the upper bound of
4343 /// buffer size required to deflate given header name/value pairs.
4344 ///
4345 /// Once this function fails, subsequent call of this function always
4346 /// returns :enum:`NGHTTP2_ERR_HEADER_COMP`.
4347 ///
4348 /// After this function returns, it is safe to delete the |nva|.
4349 ///
4350 /// This function returns the number of bytes written to |vec| if it
4351 /// succeeds, or one of the following negative error codes:
4352 ///
4353 /// :enum:`NGHTTP2_ERR_NOMEM`
4354 /// Out of memory.
4355 /// :enum:`NGHTTP2_ERR_HEADER_COMP`
4356 /// Deflation process has failed.
4357 /// :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`
4358 /// The provided |buflen| size is too small to hold the output.
4359 pub fn nghttp2_hd_deflate_hd_vec(
4360 deflater: *mut nghttp2_hd_deflater,
4361 vec: *const nghttp2_vec,
4362 veclen: usize,
4363 nva: *const nghttp2_nv,
4364 nvlen: usize,
4365 ) -> isize;
4366}
4367extern "C" {
4368 /// @function
4369 ///
4370 /// Returns an upper bound on the compressed size after deflation of
4371 /// |nva| of length |nvlen|.
4372 pub fn nghttp2_hd_deflate_bound(
4373 deflater: *mut nghttp2_hd_deflater,
4374 nva: *const nghttp2_nv,
4375 nvlen: usize,
4376 ) -> usize;
4377}
4378extern "C" {
4379 /// @function
4380 ///
4381 /// Returns the number of entries that header table of |deflater|
4382 /// contains. This is the sum of the number of static table and
4383 /// dynamic table, so the return value is at least 61.
4384 pub fn nghttp2_hd_deflate_get_num_table_entries(deflater: *mut nghttp2_hd_deflater) -> usize;
4385}
4386extern "C" {
4387 /// @function
4388 ///
4389 /// Returns the table entry denoted by |idx| from header table of
4390 /// |deflater|. The |idx| is 1-based, and idx=1 returns first entry of
4391 /// static table. idx=62 returns first entry of dynamic table if it
4392 /// exists. Specifying idx=0 is error, and this function returns NULL.
4393 /// If |idx| is strictly greater than the number of entries the tables
4394 /// contain, this function returns NULL.
4395 pub fn nghttp2_hd_deflate_get_table_entry(
4396 deflater: *mut nghttp2_hd_deflater,
4397 idx: usize,
4398 ) -> *const nghttp2_nv;
4399}
4400extern "C" {
4401 /// @function
4402 ///
4403 /// Returns the used dynamic table size, including the overhead 32
4404 /// bytes per entry described in RFC 7541.
4405 pub fn nghttp2_hd_deflate_get_dynamic_table_size(deflater: *mut nghttp2_hd_deflater) -> usize;
4406}
4407extern "C" {
4408 /// @function
4409 ///
4410 /// Returns the maximum dynamic table size.
4411 pub fn nghttp2_hd_deflate_get_max_dynamic_table_size(
4412 deflater: *mut nghttp2_hd_deflater,
4413 ) -> usize;
4414}
4415#[repr(C)]
4416#[derive(Debug, Copy, Clone)]
4417pub struct nghttp2_hd_inflater {
4418 _unused: [u8; 0],
4419}
4420extern "C" {
4421 /// @function
4422 ///
4423 /// Initializes |*inflater_ptr| for inflating name/values pairs.
4424 ///
4425 /// If this function fails, |*inflater_ptr| is left untouched.
4426 ///
4427 /// This function returns 0 if it succeeds, or one of the following
4428 /// negative error codes:
4429 ///
4430 /// :enum:`NGHTTP2_ERR_NOMEM`
4431 /// Out of memory.
4432 pub fn nghttp2_hd_inflate_new(
4433 inflater_ptr: *mut *mut nghttp2_hd_inflater,
4434 ) -> ::std::os::raw::c_int;
4435}
4436extern "C" {
4437 /// @function
4438 ///
4439 /// Like `nghttp2_hd_inflate_new()`, but with additional custom memory
4440 /// allocator specified in the |mem|.
4441 ///
4442 /// The |mem| can be ``NULL`` and the call is equivalent to
4443 /// `nghttp2_hd_inflate_new()`.
4444 ///
4445 /// This function does not take ownership |mem|. The application is
4446 /// responsible for freeing |mem|.
4447 ///
4448 /// The library code does not refer to |mem| pointer after this
4449 /// function returns, so the application can safely free it.
4450 pub fn nghttp2_hd_inflate_new2(
4451 inflater_ptr: *mut *mut nghttp2_hd_inflater,
4452 mem: *mut nghttp2_mem,
4453 ) -> ::std::os::raw::c_int;
4454}
4455extern "C" {
4456 /// @function
4457 ///
4458 /// Deallocates any resources allocated for |inflater|.
4459 pub fn nghttp2_hd_inflate_del(inflater: *mut nghttp2_hd_inflater);
4460}
4461extern "C" {
4462 /// @function
4463 ///
4464 /// Changes header table size in the |inflater|. This may trigger
4465 /// eviction in the dynamic table.
4466 ///
4467 /// The |settings_max_dynamic_table_size| should be the value
4468 /// transmitted in SETTINGS_HEADER_TABLE_SIZE.
4469 ///
4470 /// This function must not be called while header block is being
4471 /// inflated. In other words, this function must be called after
4472 /// initialization of |inflater|, but before calling
4473 /// `nghttp2_hd_inflate_hd2()`, or after
4474 /// `nghttp2_hd_inflate_end_headers()`. Otherwise,
4475 /// `NGHTTP2_ERR_INVALID_STATE` was returned.
4476 ///
4477 /// This function returns 0 if it succeeds, or one of the following
4478 /// negative error codes:
4479 ///
4480 /// :enum:`NGHTTP2_ERR_NOMEM`
4481 /// Out of memory.
4482 /// :enum:`NGHTTP2_ERR_INVALID_STATE`
4483 /// The function is called while header block is being inflated.
4484 /// Probably, application missed to call
4485 /// `nghttp2_hd_inflate_end_headers()`.
4486 pub fn nghttp2_hd_inflate_change_table_size(
4487 inflater: *mut nghttp2_hd_inflater,
4488 settings_max_dynamic_table_size: usize,
4489 ) -> ::std::os::raw::c_int;
4490}
4491/// No flag set.
4492pub const NGHTTP2_HD_INFLATE_NONE: nghttp2_hd_inflate_flag = 0;
4493/// Indicates all headers were inflated.
4494pub const NGHTTP2_HD_INFLATE_FINAL: nghttp2_hd_inflate_flag = 1;
4495/// Indicates a header was emitted.
4496pub const NGHTTP2_HD_INFLATE_EMIT: nghttp2_hd_inflate_flag = 2;
4497/// @enum
4498///
4499/// The flags for header inflation.
4500pub type nghttp2_hd_inflate_flag = u32;
4501extern "C" {
4502 /// @function
4503 ///
4504 /// .. warning::
4505 ///
4506 /// Deprecated. Use `nghttp2_hd_inflate_hd2()` instead.
4507 ///
4508 /// Inflates name/value block stored in |in| with length |inlen|. This
4509 /// function performs decompression. For each successful emission of
4510 /// header name/value pair, :enum:`NGHTTP2_HD_INFLATE_EMIT` is set in
4511 /// |*inflate_flags| and name/value pair is assigned to the |nv_out|
4512 /// and the function returns. The caller must not free the members of
4513 /// |nv_out|.
4514 ///
4515 /// The |nv_out| may include pointers to the memory region in the |in|.
4516 /// The caller must retain the |in| while the |nv_out| is used.
4517 ///
4518 /// The application should call this function repeatedly until the
4519 /// ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and
4520 /// return value is non-negative. This means the all input values are
4521 /// processed successfully. Then the application must call
4522 /// `nghttp2_hd_inflate_end_headers()` to prepare for the next header
4523 /// block input.
4524 ///
4525 /// The caller can feed complete compressed header block. It also can
4526 /// feed it in several chunks. The caller must set |in_final| to
4527 /// nonzero if the given input is the last block of the compressed
4528 /// header.
4529 ///
4530 /// This function returns the number of bytes processed if it succeeds,
4531 /// or one of the following negative error codes:
4532 ///
4533 /// :enum:`NGHTTP2_ERR_NOMEM`
4534 /// Out of memory.
4535 /// :enum:`NGHTTP2_ERR_HEADER_COMP`
4536 /// Inflation process has failed.
4537 /// :enum:`NGHTTP2_ERR_BUFFER_ERROR`
4538 /// The header field name or value is too large.
4539 ///
4540 /// Example follows::
4541 ///
4542 /// int inflate_header_block(nghttp2_hd_inflater *hd_inflater,
4543 /// uint8_t *in, size_t inlen, int final)
4544 /// {
4545 /// ssize_t rv;
4546 ///
4547 /// for(;;) {
4548 /// nghttp2_nv nv;
4549 /// int inflate_flags = 0;
4550 ///
4551 /// rv = nghttp2_hd_inflate_hd(hd_inflater, &nv, &inflate_flags,
4552 /// in, inlen, final);
4553 ///
4554 /// if(rv < 0) {
4555 /// fprintf(stderr, "inflate failed with error code %zd", rv);
4556 /// return -1;
4557 /// }
4558 ///
4559 /// in += rv;
4560 /// inlen -= rv;
4561 ///
4562 /// if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {
4563 /// fwrite(nv.name, nv.namelen, 1, stderr);
4564 /// fprintf(stderr, ": ");
4565 /// fwrite(nv.value, nv.valuelen, 1, stderr);
4566 /// fprintf(stderr, "\n");
4567 /// }
4568 /// if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) {
4569 /// nghttp2_hd_inflate_end_headers(hd_inflater);
4570 /// break;
4571 /// }
4572 /// if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 &&
4573 /// inlen == 0) {
4574 /// break;
4575 /// }
4576 /// }
4577 ///
4578 /// return 0;
4579 /// }
4580 ///
4581 pub fn nghttp2_hd_inflate_hd(
4582 inflater: *mut nghttp2_hd_inflater,
4583 nv_out: *mut nghttp2_nv,
4584 inflate_flags: *mut ::std::os::raw::c_int,
4585 in_: *mut u8,
4586 inlen: usize,
4587 in_final: ::std::os::raw::c_int,
4588 ) -> isize;
4589}
4590extern "C" {
4591 /// @function
4592 ///
4593 /// Inflates name/value block stored in |in| with length |inlen|. This
4594 /// function performs decompression. For each successful emission of
4595 /// header name/value pair, :enum:`NGHTTP2_HD_INFLATE_EMIT` is set in
4596 /// |*inflate_flags| and name/value pair is assigned to the |nv_out|
4597 /// and the function returns. The caller must not free the members of
4598 /// |nv_out|.
4599 ///
4600 /// The |nv_out| may include pointers to the memory region in the |in|.
4601 /// The caller must retain the |in| while the |nv_out| is used.
4602 ///
4603 /// The application should call this function repeatedly until the
4604 /// ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and
4605 /// return value is non-negative. If that happens, all given input
4606 /// data (|inlen| bytes) are processed successfully. Then the
4607 /// application must call `nghttp2_hd_inflate_end_headers()` to prepare
4608 /// for the next header block input.
4609 ///
4610 /// In other words, if |in_final| is nonzero, and this function returns
4611 /// |inlen|, you can assert that :enum:`NGHTTP2_HD_INFLATE_FINAL` is
4612 /// set in |*inflate_flags|.
4613 ///
4614 /// The caller can feed complete compressed header block. It also can
4615 /// feed it in several chunks. The caller must set |in_final| to
4616 /// nonzero if the given input is the last block of the compressed
4617 /// header.
4618 ///
4619 /// This function returns the number of bytes processed if it succeeds,
4620 /// or one of the following negative error codes:
4621 ///
4622 /// :enum:`NGHTTP2_ERR_NOMEM`
4623 /// Out of memory.
4624 /// :enum:`NGHTTP2_ERR_HEADER_COMP`
4625 /// Inflation process has failed.
4626 /// :enum:`NGHTTP2_ERR_BUFFER_ERROR`
4627 /// The header field name or value is too large.
4628 ///
4629 /// Example follows::
4630 ///
4631 /// int inflate_header_block(nghttp2_hd_inflater *hd_inflater,
4632 /// uint8_t *in, size_t inlen, int final)
4633 /// {
4634 /// ssize_t rv;
4635 ///
4636 /// for(;;) {
4637 /// nghttp2_nv nv;
4638 /// int inflate_flags = 0;
4639 ///
4640 /// rv = nghttp2_hd_inflate_hd2(hd_inflater, &nv, &inflate_flags,
4641 /// in, inlen, final);
4642 ///
4643 /// if(rv < 0) {
4644 /// fprintf(stderr, "inflate failed with error code %zd", rv);
4645 /// return -1;
4646 /// }
4647 ///
4648 /// in += rv;
4649 /// inlen -= rv;
4650 ///
4651 /// if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {
4652 /// fwrite(nv.name, nv.namelen, 1, stderr);
4653 /// fprintf(stderr, ": ");
4654 /// fwrite(nv.value, nv.valuelen, 1, stderr);
4655 /// fprintf(stderr, "\n");
4656 /// }
4657 /// if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) {
4658 /// nghttp2_hd_inflate_end_headers(hd_inflater);
4659 /// break;
4660 /// }
4661 /// if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 &&
4662 /// inlen == 0) {
4663 /// break;
4664 /// }
4665 /// }
4666 ///
4667 /// return 0;
4668 /// }
4669 ///
4670 pub fn nghttp2_hd_inflate_hd2(
4671 inflater: *mut nghttp2_hd_inflater,
4672 nv_out: *mut nghttp2_nv,
4673 inflate_flags: *mut ::std::os::raw::c_int,
4674 in_: *const u8,
4675 inlen: usize,
4676 in_final: ::std::os::raw::c_int,
4677 ) -> isize;
4678}
4679extern "C" {
4680 /// @function
4681 ///
4682 /// Signals the end of decompression for one header block.
4683 ///
4684 /// This function returns 0 if it succeeds. Currently this function
4685 /// always succeeds.
4686 pub fn nghttp2_hd_inflate_end_headers(
4687 inflater: *mut nghttp2_hd_inflater,
4688 ) -> ::std::os::raw::c_int;
4689}
4690extern "C" {
4691 /// @function
4692 ///
4693 /// Returns the number of entries that header table of |inflater|
4694 /// contains. This is the sum of the number of static table and
4695 /// dynamic table, so the return value is at least 61.
4696 pub fn nghttp2_hd_inflate_get_num_table_entries(inflater: *mut nghttp2_hd_inflater) -> usize;
4697}
4698extern "C" {
4699 /// @function
4700 ///
4701 /// Returns the table entry denoted by |idx| from header table of
4702 /// |inflater|. The |idx| is 1-based, and idx=1 returns first entry of
4703 /// static table. idx=62 returns first entry of dynamic table if it
4704 /// exists. Specifying idx=0 is error, and this function returns NULL.
4705 /// If |idx| is strictly greater than the number of entries the tables
4706 /// contain, this function returns NULL.
4707 pub fn nghttp2_hd_inflate_get_table_entry(
4708 inflater: *mut nghttp2_hd_inflater,
4709 idx: usize,
4710 ) -> *const nghttp2_nv;
4711}
4712extern "C" {
4713 /// @function
4714 ///
4715 /// Returns the used dynamic table size, including the overhead 32
4716 /// bytes per entry described in RFC 7541.
4717 pub fn nghttp2_hd_inflate_get_dynamic_table_size(inflater: *mut nghttp2_hd_inflater) -> usize;
4718}
4719extern "C" {
4720 /// @function
4721 ///
4722 /// Returns the maximum dynamic table size.
4723 pub fn nghttp2_hd_inflate_get_max_dynamic_table_size(
4724 inflater: *mut nghttp2_hd_inflater,
4725 ) -> usize;
4726}
4727#[repr(C)]
4728#[derive(Debug, Copy, Clone)]
4729pub struct nghttp2_stream {
4730 _unused: [u8; 0],
4731}
4732extern "C" {
4733 /// @function
4734 ///
4735 /// Returns pointer to :type:`nghttp2_stream` object denoted by
4736 /// |stream_id|. If stream was not found, returns NULL.
4737 ///
4738 /// Returns imaginary root stream (see
4739 /// `nghttp2_session_get_root_stream()`) if 0 is given in |stream_id|.
4740 ///
4741 /// Unless |stream_id| == 0, the returned pointer is valid until next
4742 /// call of `nghttp2_session_send()`, `nghttp2_session_mem_send()`,
4743 /// `nghttp2_session_recv()`, and `nghttp2_session_mem_recv()`.
4744 pub fn nghttp2_session_find_stream(
4745 session: *mut nghttp2_session,
4746 stream_id: i32,
4747 ) -> *mut nghttp2_stream;
4748}
4749/// idle state.
4750pub const NGHTTP2_STREAM_STATE_IDLE: nghttp2_stream_proto_state = 1;
4751/// open state.
4752pub const NGHTTP2_STREAM_STATE_OPEN: nghttp2_stream_proto_state = 2;
4753/// reserved (local) state.
4754pub const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: nghttp2_stream_proto_state = 3;
4755/// reserved (remote) state.
4756pub const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: nghttp2_stream_proto_state = 4;
4757/// half closed (local) state.
4758pub const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: nghttp2_stream_proto_state = 5;
4759/// half closed (remote) state.
4760pub const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: nghttp2_stream_proto_state = 6;
4761/// closed state.
4762pub const NGHTTP2_STREAM_STATE_CLOSED: nghttp2_stream_proto_state = 7;
4763/// @enum
4764///
4765/// State of stream as described in RFC 7540.
4766pub type nghttp2_stream_proto_state = u32;
4767extern "C" {
4768 /// @function
4769 ///
4770 /// Returns state of |stream|. The root stream retrieved by
4771 /// `nghttp2_session_get_root_stream()` will have stream state
4772 /// :enum:`NGHTTP2_STREAM_STATE_IDLE`.
4773 pub fn nghttp2_stream_get_state(stream: *mut nghttp2_stream) -> nghttp2_stream_proto_state;
4774}
4775extern "C" {
4776 /// @function
4777 ///
4778 /// Returns root of dependency tree, which is imaginary stream with
4779 /// stream ID 0. The returned pointer is valid until |session| is
4780 /// freed by `nghttp2_session_del()`.
4781 pub fn nghttp2_session_get_root_stream(session: *mut nghttp2_session) -> *mut nghttp2_stream;
4782}
4783extern "C" {
4784 /// @function
4785 ///
4786 /// Returns the parent stream of |stream| in dependency tree. Returns
4787 /// NULL if there is no such stream.
4788 pub fn nghttp2_stream_get_parent(stream: *mut nghttp2_stream) -> *mut nghttp2_stream;
4789}
4790extern "C" {
4791 pub fn nghttp2_stream_get_stream_id(stream: *mut nghttp2_stream) -> i32;
4792}
4793extern "C" {
4794 /// @function
4795 ///
4796 /// Returns the next sibling stream of |stream| in dependency tree.
4797 /// Returns NULL if there is no such stream.
4798 pub fn nghttp2_stream_get_next_sibling(stream: *mut nghttp2_stream) -> *mut nghttp2_stream;
4799}
4800extern "C" {
4801 /// @function
4802 ///
4803 /// Returns the previous sibling stream of |stream| in dependency tree.
4804 /// Returns NULL if there is no such stream.
4805 pub fn nghttp2_stream_get_previous_sibling(stream: *mut nghttp2_stream) -> *mut nghttp2_stream;
4806}
4807extern "C" {
4808 /// @function
4809 ///
4810 /// Returns the first child stream of |stream| in dependency tree.
4811 /// Returns NULL if there is no such stream.
4812 pub fn nghttp2_stream_get_first_child(stream: *mut nghttp2_stream) -> *mut nghttp2_stream;
4813}
4814extern "C" {
4815 /// @function
4816 ///
4817 /// Returns dependency weight to the parent stream of |stream|.
4818 pub fn nghttp2_stream_get_weight(stream: *mut nghttp2_stream) -> i32;
4819}
4820extern "C" {
4821 /// @function
4822 ///
4823 /// Returns the sum of the weight for |stream|'s children.
4824 pub fn nghttp2_stream_get_sum_dependency_weight(stream: *mut nghttp2_stream) -> i32;
4825}