nghttp2_http.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2015-2018 Alibaba Group Holding Limited
  3. */
  4. #ifndef NGHTTP2_HTTP_H
  5. #define NGHTTP2_HTTP_H
  6. #ifdef HAVE_CONFIG_H
  7. #include <config.h>
  8. #endif /* HAVE_CONFIG_H */
  9. #include "nghttp2.h"
  10. #include "nghttp2_session.h"
  11. #include "nghttp2_stream.h"
  12. /*
  13. * This function is called when HTTP header field |nv| in |frame| is
  14. * received for |stream|. This function will validate |nv| against
  15. * the current state of stream.
  16. *
  17. * This function returns 0 if it succeeds, or one of the following
  18. * negative error codes:
  19. *
  20. * NGHTTP2_ERR_HTTP_HEADER
  21. * Invalid HTTP header field was received.
  22. * NGHTTP2_ERR_IGN_HTTP_HEADER
  23. * Invalid HTTP header field was received but it can be treated as
  24. * if it was not received because of compatibility reasons.
  25. */
  26. int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
  27. nghttp2_frame *frame, nghttp2_hd_nv *nv,
  28. int trailer);
  29. /*
  30. * This function is called when request header is received. This
  31. * function performs validation and returns 0 if it succeeds, or -1.
  32. */
  33. int nghttp2_http_on_request_headers(nghttp2_stream *stream,
  34. nghttp2_frame *frame);
  35. /*
  36. * This function is called when response header is received. This
  37. * function performs validation and returns 0 if it succeeds, or -1.
  38. */
  39. int nghttp2_http_on_response_headers(nghttp2_stream *stream);
  40. /*
  41. * This function is called trailer header (for both request and
  42. * response) is received. This function performs validation and
  43. * returns 0 if it succeeds, or -1.
  44. */
  45. int nghttp2_http_on_trailer_headers(nghttp2_stream *stream,
  46. nghttp2_frame *frame);
  47. /*
  48. * This function is called when END_STREAM flag is seen in incoming
  49. * frame. This function performs validation and returns 0 if it
  50. * succeeds, or -1.
  51. */
  52. int nghttp2_http_on_remote_end_stream(nghttp2_stream *stream);
  53. /*
  54. * This function is called when chunk of data is received. This
  55. * function performs validation and returns 0 if it succeeds, or -1.
  56. */
  57. int nghttp2_http_on_data_chunk(nghttp2_stream *stream, size_t n);
  58. /*
  59. * This function inspects header field in |frame| and records its
  60. * method in stream->http_flags. If frame->hd.type is neither
  61. * NGHTTP2_HEADERS nor NGHTTP2_PUSH_PROMISE, this function does
  62. * nothing.
  63. */
  64. void nghttp2_http_record_request_method(nghttp2_stream *stream,
  65. nghttp2_frame *frame);
  66. #endif /* NGHTTP2_HTTP_H */