nghttp2_callbacks.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. * Callback function invoked when the session wants to send data to
  37. * the remote peer. This callback is not necessary if the
  38. * application uses solely `nghttp2_session_mem_send()` to serialize
  39. * data to transmit.
  40. */
  41. nghttp2_send_callback send_callback;
  42. /**
  43. * Callback function invoked when the session wants to receive data
  44. * from the remote peer. This callback is not necessary if the
  45. * application uses solely `nghttp2_session_mem_recv()` to process
  46. * received data.
  47. */
  48. nghttp2_recv_callback recv_callback;
  49. /**
  50. * Callback function invoked by `nghttp2_session_recv()` when a
  51. * frame is received.
  52. */
  53. nghttp2_on_frame_recv_callback on_frame_recv_callback;
  54. /**
  55. * Callback function invoked by `nghttp2_session_recv()` when an
  56. * invalid non-DATA frame is received.
  57. */
  58. nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback;
  59. /**
  60. * Callback function invoked when a chunk of data in DATA frame is
  61. * received.
  62. */
  63. nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback;
  64. /**
  65. * Callback function invoked before a non-DATA frame is sent.
  66. */
  67. nghttp2_before_frame_send_callback before_frame_send_callback;
  68. /**
  69. * Callback function invoked after a frame is sent.
  70. */
  71. nghttp2_on_frame_send_callback on_frame_send_callback;
  72. /**
  73. * The callback function invoked when a non-DATA frame is not sent
  74. * because of an error.
  75. */
  76. nghttp2_on_frame_not_send_callback on_frame_not_send_callback;
  77. /**
  78. * Callback function invoked when the stream is closed.
  79. */
  80. nghttp2_on_stream_close_callback on_stream_close_callback;
  81. /**
  82. * Callback function invoked when the reception of header block in
  83. * HEADERS or PUSH_PROMISE is started.
  84. */
  85. nghttp2_on_begin_headers_callback on_begin_headers_callback;
  86. /**
  87. * Callback function invoked when a header name/value pair is
  88. * received.
  89. */
  90. nghttp2_on_header_callback on_header_callback;
  91. nghttp2_on_header_callback2 on_header_callback2;
  92. /**
  93. * Callback function invoked when a invalid header name/value pair
  94. * is received which is silently ignored if these callbacks are not
  95. * set.
  96. */
  97. nghttp2_on_invalid_header_callback on_invalid_header_callback;
  98. nghttp2_on_invalid_header_callback2 on_invalid_header_callback2;
  99. /**
  100. * Callback function invoked when the library asks application how
  101. * many padding bytes are required for the transmission of the given
  102. * frame.
  103. */
  104. nghttp2_select_padding_callback select_padding_callback;
  105. /**
  106. * The callback function used to determine the length allowed in
  107. * `nghttp2_data_source_read_callback()`
  108. */
  109. nghttp2_data_source_read_length_callback read_length_callback;
  110. /**
  111. * Sets callback function invoked when a frame header is received.
  112. */
  113. nghttp2_on_begin_frame_callback on_begin_frame_callback;
  114. nghttp2_send_data_callback send_data_callback;
  115. nghttp2_pack_extension_callback pack_extension_callback;
  116. nghttp2_unpack_extension_callback unpack_extension_callback;
  117. nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback;
  118. nghttp2_error_callback error_callback;
  119. nghttp2_error_callback2 error_callback2;
  120. };
  121. #endif /* NGHTTP2_CALLBACKS_H */