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.
28 #include "nghttp2_config.h"
32 #ifdef HAVE_SYS_TIME_H
34 #endif // HAVE_SYS_TIME_H
40 #include <nghttp2/nghttp2.h>
44 int verbose_on_header_callback(nghttp2_session *session,
45 const nghttp2_frame *frame, const uint8_t *name,
46 size_t namelen, const uint8_t *value,
47 size_t valuelen, uint8_t flags, void *user_data);
49 int verbose_on_frame_recv_callback(nghttp2_session *session,
50 const nghttp2_frame *frame, void *user_data);
52 int verbose_on_invalid_frame_recv_callback(nghttp2_session *session,
53 const nghttp2_frame *frame,
54 int lib_error_code, void *user_data);
56 int verbose_on_frame_send_callback(nghttp2_session *session,
57 const nghttp2_frame *frame, void *user_data);
59 int verbose_on_data_chunk_recv_callback(nghttp2_session *session, uint8_t flags,
60 int32_t stream_id, const uint8_t *data,
61 size_t len, void *user_data);
63 // Returns difference between |a| and |b| in milliseconds, assuming
64 // |a| is more recent than |b|.
65 template <typename TimePoint>
66 std::chrono::milliseconds time_delta(const TimePoint &a, const TimePoint &b) {
67 return std::chrono::duration_cast<std::chrono::milliseconds>(a - b);
73 // Returns the duration since timer reset.
74 std::chrono::milliseconds get_timer();
76 // Returns current time point.
77 std::chrono::steady_clock::time_point get_time();
81 // Setting true will print characters with ANSI color escape codes
82 // when printing HTTP2 frames. This function changes a static
84 void set_color_output(bool f);
86 // Set output file when printing HTTP2 frames. By default, stdout is
88 void set_output(FILE *file);
90 ssize_t deflate_data(uint8_t *out, size_t outlen, const uint8_t *in,
93 } // namespace nghttp2
95 #endif // APP_HELPER_H