nghttp2_callbacks.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2015-2018 Alibaba Group Holding Limited
  3. */
  4. #ifndef NGHTTP2_CALLBACKS_H
  5. #define NGHTTP2_CALLBACKS_H
  6. #ifdef HAVE_CONFIG_H
  7. #include <config.h>
  8. #endif /* HAVE_CONFIG_H */
  9. #include "nghttp2.h"
  10. /*
  11. * Callback functions.
  12. */
  13. struct nghttp2_session_callbacks {
  14. /**
  15. * Callback function invoked when the session wants to send data to
  16. * the remote peer. This callback is not necessary if the
  17. * application uses solely `nghttp2_session_mem_send()` to serialize
  18. * data to transmit.
  19. */
  20. nghttp2_send_callback send_callback;
  21. /**
  22. * Callback function invoked when the session wants to receive data
  23. * from the remote peer. This callback is not necessary if the
  24. * application uses solely `nghttp2_session_mem_recv()` to process
  25. * received data.
  26. */
  27. nghttp2_recv_callback recv_callback;
  28. /**
  29. * Callback function invoked by `nghttp2_session_recv()` when a
  30. * frame is received.
  31. */
  32. nghttp2_on_frame_recv_callback on_frame_recv_callback;
  33. /**
  34. * Callback function invoked by `nghttp2_session_recv()` when an
  35. * invalid non-DATA frame is received.
  36. */
  37. nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback;
  38. /**
  39. * Callback function invoked when a chunk of data in DATA frame is
  40. * received.
  41. */
  42. nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback;
  43. /**
  44. * Callback function invoked before a non-DATA frame is sent.
  45. */
  46. nghttp2_before_frame_send_callback before_frame_send_callback;
  47. /**
  48. * Callback function invoked after a frame is sent.
  49. */
  50. nghttp2_on_frame_send_callback on_frame_send_callback;
  51. /**
  52. * The callback function invoked when a non-DATA frame is not sent
  53. * because of an error.
  54. */
  55. nghttp2_on_frame_not_send_callback on_frame_not_send_callback;
  56. /**
  57. * Callback function invoked when the stream is closed.
  58. */
  59. nghttp2_on_stream_close_callback on_stream_close_callback;
  60. /**
  61. * Callback function invoked when the reception of header block in
  62. * HEADERS or PUSH_PROMISE is started.
  63. */
  64. nghttp2_on_begin_headers_callback on_begin_headers_callback;
  65. /**
  66. * Callback function invoked when a header name/value pair is
  67. * received.
  68. */
  69. nghttp2_on_header_callback on_header_callback;
  70. nghttp2_on_header_callback2 on_header_callback2;
  71. /**
  72. * Callback function invoked when a invalid header name/value pair
  73. * is received which is silently ignored if these callbacks are not
  74. * set.
  75. */
  76. nghttp2_on_invalid_header_callback on_invalid_header_callback;
  77. nghttp2_on_invalid_header_callback2 on_invalid_header_callback2;
  78. /**
  79. * Callback function invoked when the library asks application how
  80. * many padding bytes are required for the transmission of the given
  81. * frame.
  82. */
  83. nghttp2_select_padding_callback select_padding_callback;
  84. /**
  85. * The callback function used to determine the length allowed in
  86. * `nghttp2_data_source_read_callback()`
  87. */
  88. nghttp2_data_source_read_length_callback read_length_callback;
  89. /**
  90. * Sets callback function invoked when a frame header is received.
  91. */
  92. nghttp2_on_begin_frame_callback on_begin_frame_callback;
  93. nghttp2_send_data_callback send_data_callback;
  94. nghttp2_pack_extension_callback pack_extension_callback;
  95. nghttp2_unpack_extension_callback unpack_extension_callback;
  96. nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback;
  97. nghttp2_error_callback error_callback;
  98. nghttp2_error_callback2 error_callback2;
  99. };
  100. #endif /* NGHTTP2_CALLBACKS_H */