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