• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * nghttp2 - HTTP/2 C Library
3  *
4  * Copyright (c) 2014 Tatsuhiro Tsujikawa
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #ifndef NGHTTP2_CALLBACKS_H
26 #define NGHTTP2_CALLBACKS_H
27 
28 #ifdef HAVE_CONFIG_H
29 #  include <config.h>
30 #endif /* HAVE_CONFIG_H */
31 
32 #include <nghttp2/nghttp2.h>
33 
34 /*
35  * Callback functions.
36  */
37 struct nghttp2_session_callbacks {
38   /**
39    * Callback function invoked when the session wants to send data to
40    * the remote peer.  This callback is not necessary if the
41    * application uses solely `nghttp2_session_mem_send()` to serialize
42    * data to transmit.
43    */
44   nghttp2_send_callback send_callback;
45   /**
46    * Callback function invoked when the session wants to receive data
47    * from the remote peer.  This callback is not necessary if the
48    * application uses solely `nghttp2_session_mem_recv()` to process
49    * received data.
50    */
51   nghttp2_recv_callback recv_callback;
52   /**
53    * Callback function invoked by `nghttp2_session_recv()` when a
54    * frame is received.
55    */
56   nghttp2_on_frame_recv_callback on_frame_recv_callback;
57   /**
58    * Callback function invoked by `nghttp2_session_recv()` when an
59    * invalid non-DATA frame is received.
60    */
61   nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback;
62   /**
63    * Callback function invoked when a chunk of data in DATA frame is
64    * received.
65    */
66   nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback;
67   /**
68    * Callback function invoked before a non-DATA frame is sent.
69    */
70   nghttp2_before_frame_send_callback before_frame_send_callback;
71   /**
72    * Callback function invoked after a frame is sent.
73    */
74   nghttp2_on_frame_send_callback on_frame_send_callback;
75   /**
76    * The callback function invoked when a non-DATA frame is not sent
77    * because of an error.
78    */
79   nghttp2_on_frame_not_send_callback on_frame_not_send_callback;
80   /**
81    * Callback function invoked when the stream is closed.
82    */
83   nghttp2_on_stream_close_callback on_stream_close_callback;
84   /**
85    * Callback function invoked when the reception of header block in
86    * HEADERS or PUSH_PROMISE is started.
87    */
88   nghttp2_on_begin_headers_callback on_begin_headers_callback;
89   /**
90    * Callback function invoked when a header name/value pair is
91    * received.
92    */
93   nghttp2_on_header_callback on_header_callback;
94   nghttp2_on_header_callback2 on_header_callback2;
95   /**
96    * Callback function invoked when a invalid header name/value pair
97    * is received which is silently ignored if these callbacks are not
98    * set.
99    */
100   nghttp2_on_invalid_header_callback on_invalid_header_callback;
101   nghttp2_on_invalid_header_callback2 on_invalid_header_callback2;
102   /**
103    * Callback function invoked when the library asks application how
104    * many padding bytes are required for the transmission of the given
105    * frame.
106    */
107   nghttp2_select_padding_callback select_padding_callback;
108   /**
109    * The callback function used to determine the length allowed in
110    * `nghttp2_data_source_read_callback()`
111    */
112   nghttp2_data_source_read_length_callback read_length_callback;
113   /**
114    * Sets callback function invoked when a frame header is received.
115    */
116   nghttp2_on_begin_frame_callback on_begin_frame_callback;
117   nghttp2_send_data_callback send_data_callback;
118   nghttp2_pack_extension_callback pack_extension_callback;
119   nghttp2_unpack_extension_callback unpack_extension_callback;
120   nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback;
121   nghttp2_error_callback error_callback;
122   nghttp2_error_callback2 error_callback2;
123 };
124 
125 #endif /* NGHTTP2_CALLBACKS_H */
126