nghttp2_http.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * nghttp2 - HTTP/2 C Library
  3. *
  4. * Copyright (c) 2015 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_HTTP_H
  26. #define NGHTTP2_HTTP_H
  27. #ifdef HAVE_CONFIG_H
  28. # include <config.h>
  29. #endif /* HAVE_CONFIG_H */
  30. #include <nghttp2/nghttp2.h>
  31. #include "nghttp2_session.h"
  32. #include "nghttp2_stream.h"
  33. /*
  34. * This function is called when HTTP header field |nv| in |frame| is
  35. * received for |stream|. This function will validate |nv| against
  36. * the current state of stream.
  37. *
  38. * This function returns 0 if it succeeds, or one of the following
  39. * negative error codes:
  40. *
  41. * NGHTTP2_ERR_HTTP_HEADER
  42. * Invalid HTTP header field was received.
  43. * NGHTTP2_ERR_IGN_HTTP_HEADER
  44. * Invalid HTTP header field was received but it can be treated as
  45. * if it was not received because of compatibility reasons.
  46. */
  47. int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
  48. nghttp2_frame *frame, nghttp2_hd_nv *nv,
  49. int trailer);
  50. /*
  51. * This function is called when request header is received. This
  52. * function performs validation and returns 0 if it succeeds, or -1.
  53. */
  54. int nghttp2_http_on_request_headers(nghttp2_stream *stream,
  55. nghttp2_frame *frame);
  56. /*
  57. * This function is called when response header is received. This
  58. * function performs validation and returns 0 if it succeeds, or -1.
  59. */
  60. int nghttp2_http_on_response_headers(nghttp2_stream *stream);
  61. /*
  62. * This function is called trailer header (for both request and
  63. * response) is received. This function performs validation and
  64. * returns 0 if it succeeds, or -1.
  65. */
  66. int nghttp2_http_on_trailer_headers(nghttp2_stream *stream,
  67. nghttp2_frame *frame);
  68. /*
  69. * This function is called when END_STREAM flag is seen in incoming
  70. * frame. This function performs validation and returns 0 if it
  71. * succeeds, or -1.
  72. */
  73. int nghttp2_http_on_remote_end_stream(nghttp2_stream *stream);
  74. /*
  75. * This function is called when chunk of data is received. This
  76. * function performs validation and returns 0 if it succeeds, or -1.
  77. */
  78. int nghttp2_http_on_data_chunk(nghttp2_stream *stream, size_t n);
  79. /*
  80. * This function inspects header field in |frame| and records its
  81. * method in stream->http_flags. If frame->hd.type is neither
  82. * NGHTTP2_HEADERS nor NGHTTP2_PUSH_PROMISE, this function does
  83. * nothing.
  84. */
  85. void nghttp2_http_record_request_method(nghttp2_stream *stream,
  86. nghttp2_frame *frame);
  87. int nghttp2_http_parse_priority(nghttp2_extpri *dest, const uint8_t *value,
  88. size_t valuelen);
  89. #endif /* NGHTTP2_HTTP_H */