2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2012 Tatsuhiro Tsujikawa
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:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
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.
32 #include <nghttp2/nghttp2.h>
34 #include "shrpx_config.h"
36 #include "allocator.h"
38 using namespace nghttp2;
44 StringRef create_error_html(BlockAllocator &balloc, unsigned int status_code);
46 template <typename OutputIt>
47 OutputIt create_via_header_value(OutputIt dst, int major, int minor) {
48 *dst++ = static_cast<char>(major + '0');
51 *dst++ = static_cast<char>(minor + '0');
53 return util::copy_lit(dst, " nghttpx");
56 // Returns generated RFC 7239 Forwarded header field value. The
57 // |params| is bitwise-OR of zero or more of shrpx_forwarded_param
58 // defined in shrpx_config.h.
59 StringRef create_forwarded(BlockAllocator &balloc, int params,
60 const StringRef &node_by, const StringRef &node_for,
61 const StringRef &host, const StringRef &proto);
63 // Adds ANSI color codes to HTTP headers |hdrs|.
64 std::string colorizeHeaders(const char *hdrs);
66 ssize_t select_padding_callback(nghttp2_session *session,
67 const nghttp2_frame *frame, size_t max_payload,
70 // Creates set-cookie-string for cookie based affinity. If |path| is
71 // not empty, "; <path>" is added. If |secure| is true, "; Secure" is
73 StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name,
74 uint32_t affinity_cookie,
75 const StringRef &path, bool secure);
77 // Returns true if |secure| indicates that Secure attribute should be
79 bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure,
80 const StringRef &scheme);
86 #endif // SHRPX_HTTP_H