nghttp2_callbacks.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. #ifdef HAVE_CONFIG_H
  28. # include <config.h>
  29. #endif /* HAVE_CONFIG_H */
  30. #include <nghttp2/nghttp2.h>
  31. /*
  32. * Callback functions.
  33. */
  34. struct nghttp2_session_callbacks {
  35. /**
  36. * Deprecated. Use send_callback2 instead. Callback function
  37. * invoked when the session wants to send data to the remote peer.
  38. * This callback is not necessary if the application uses solely
  39. * `nghttp2_session_mem_send()` to serialize data to transmit.
  40. */
  41. nghttp2_send_callback send_callback;
  42. /**
  43. * Callback function invoked when the session wants to send data to
  44. * the remote peer. This callback is not necessary if the
  45. * application uses solely `nghttp2_session_mem_send2()` to
  46. * serialize data to transmit.
  47. */
  48. nghttp2_send_callback2 send_callback2;
  49. /**
  50. * Deprecated. Use recv_callback2 instead. Callback function
  51. * invoked when the session wants to receive data from the remote
  52. * peer. This callback is not necessary if the application uses
  53. * solely `nghttp2_session_mem_recv()` to process received data.
  54. */
  55. nghttp2_recv_callback recv_callback;
  56. /**
  57. * Callback function invoked when the session wants to receive data
  58. * from the remote peer. This callback is not necessary if the
  59. * application uses solely `nghttp2_session_mem_recv2()` to process
  60. * received data.
  61. */
  62. nghttp2_recv_callback2 recv_callback2;
  63. /**
  64. * Callback function invoked by `nghttp2_session_recv()` when a
  65. * frame is received.
  66. */
  67. nghttp2_on_frame_recv_callback on_frame_recv_callback;
  68. /**
  69. * Callback function invoked by `nghttp2_session_recv()` when an
  70. * invalid non-DATA frame is received.
  71. */
  72. nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback;
  73. /**
  74. * Callback function invoked when a chunk of data in DATA frame is
  75. * received.
  76. */
  77. nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback;
  78. /**
  79. * Callback function invoked before a non-DATA frame is sent.
  80. */
  81. nghttp2_before_frame_send_callback before_frame_send_callback;
  82. /**
  83. * Callback function invoked after a frame is sent.
  84. */
  85. nghttp2_on_frame_send_callback on_frame_send_callback;
  86. /**
  87. * The callback function invoked when a non-DATA frame is not sent
  88. * because of an error.
  89. */
  90. nghttp2_on_frame_not_send_callback on_frame_not_send_callback;
  91. /**
  92. * Callback function invoked when the stream is closed.
  93. */
  94. nghttp2_on_stream_close_callback on_stream_close_callback;
  95. /**
  96. * Callback function invoked when the reception of header block in
  97. * HEADERS or PUSH_PROMISE is started.
  98. */
  99. nghttp2_on_begin_headers_callback on_begin_headers_callback;
  100. /**
  101. * Callback function invoked when a header name/value pair is
  102. * received.
  103. */
  104. nghttp2_on_header_callback on_header_callback;
  105. nghttp2_on_header_callback2 on_header_callback2;
  106. /**
  107. * Callback function invoked when a invalid header name/value pair
  108. * is received which is silently ignored if these callbacks are not
  109. * set.
  110. */
  111. nghttp2_on_invalid_header_callback on_invalid_header_callback;
  112. nghttp2_on_invalid_header_callback2 on_invalid_header_callback2;
  113. /**
  114. * Deprecated. Use select_padding_callback2 instead. Callback
  115. * function invoked when the library asks application how many
  116. * padding bytes are required for the transmission of the given
  117. * frame.
  118. */
  119. nghttp2_select_padding_callback select_padding_callback;
  120. /**
  121. * Callback function invoked when the library asks application how
  122. * many padding bytes are required for the transmission of the given
  123. * frame.
  124. */
  125. nghttp2_select_padding_callback2 select_padding_callback2;
  126. /**
  127. * Deprecated. Use read_length_callback2 instead. The callback
  128. * function used to determine the length allowed in
  129. * `nghttp2_data_source_read_callback()`
  130. */
  131. nghttp2_data_source_read_length_callback read_length_callback;
  132. /**
  133. * The callback function used to determine the length allowed in
  134. * `nghttp2_data_source_read_callback2()`
  135. */
  136. nghttp2_data_source_read_length_callback2 read_length_callback2;
  137. /**
  138. * Sets callback function invoked when a frame header is received.
  139. */
  140. nghttp2_on_begin_frame_callback on_begin_frame_callback;
  141. nghttp2_send_data_callback send_data_callback;
  142. /**
  143. * Deprecated. Use pack_extension_callback2 instead.
  144. */
  145. nghttp2_pack_extension_callback pack_extension_callback;
  146. nghttp2_pack_extension_callback2 pack_extension_callback2;
  147. nghttp2_unpack_extension_callback unpack_extension_callback;
  148. nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback;
  149. nghttp2_error_callback error_callback;
  150. nghttp2_error_callback2 error_callback2;
  151. };
  152. #endif /* NGHTTP2_CALLBACKS_H */