Switch to clang-format-3.6
This commit is contained in:
parent
7c613386db
commit
c6ef1c02b9
|
@ -27,7 +27,7 @@ We use clang-format to format source code consistently. The
|
||||||
clang-format configuration file .clang-format is located at the root
|
clang-format configuration file .clang-format is located at the root
|
||||||
directory. Since clang-format produces slightly different results
|
directory. Since clang-format produces slightly different results
|
||||||
between versions, we currently use clang-format which comes with
|
between versions, we currently use clang-format which comes with
|
||||||
clang-3.5.
|
clang-3.6.
|
||||||
|
|
||||||
To detect any violation to the coding style, we recommend to setup git
|
To detect any violation to the coding style, we recommend to setup git
|
||||||
pre-commit hook to check coding style of the changes you introduced.
|
pre-commit hook to check coding style of the changes you introduced.
|
||||||
|
@ -35,7 +35,7 @@ The pre-commit file is located at the root directory. Copy it under
|
||||||
.git/hooks and make sure that it is executable. The pre-commit script
|
.git/hooks and make sure that it is executable. The pre-commit script
|
||||||
uses clang-format-diff.py to detect any style errors. If it is not in
|
uses clang-format-diff.py to detect any style errors. If it is not in
|
||||||
your PATH or it exists under different name (e.g.,
|
your PATH or it exists under different name (e.g.,
|
||||||
clang-format-diff-3.5 in debian), either add it to PATH variable or
|
clang-format-diff-3.6 in debian), either add it to PATH variable or
|
||||||
add git option ``clangformatdiff.binary`` to point to the script.
|
add git option ``clangformatdiff.binary`` to point to the script.
|
||||||
|
|
||||||
For emacs users, integrating clang-format to emacs is very easy.
|
For emacs users, integrating clang-format to emacs is very easy.
|
||||||
|
|
|
@ -459,12 +459,11 @@ static void ctl_poll(struct pollfd *pollfd, struct Connection *connection) {
|
||||||
static void submit_request(struct Connection *connection, struct Request *req) {
|
static void submit_request(struct Connection *connection, struct Request *req) {
|
||||||
int32_t stream_id;
|
int32_t stream_id;
|
||||||
/* Make sure that the last item is NULL */
|
/* Make sure that the last item is NULL */
|
||||||
const nghttp2_nv nva[] = {MAKE_NV(":method", "GET"),
|
const nghttp2_nv nva[] = {
|
||||||
MAKE_NV_CS(":path", req->path),
|
MAKE_NV(":method", "GET"), MAKE_NV_CS(":path", req->path),
|
||||||
MAKE_NV(":scheme", "https"),
|
MAKE_NV(":scheme", "https"), MAKE_NV_CS(":authority", req->hostport),
|
||||||
MAKE_NV_CS(":authority", req->hostport),
|
MAKE_NV("accept", "*/*"),
|
||||||
MAKE_NV("accept", "*/*"),
|
MAKE_NV("user-agent", "nghttp2/" NGHTTP2_VERSION)};
|
||||||
MAKE_NV("user-agent", "nghttp2/" NGHTTP2_VERSION)};
|
|
||||||
|
|
||||||
stream_id = nghttp2_submit_request(connection->session, NULL, nva,
|
stream_id = nghttp2_submit_request(connection->session, NULL, nva,
|
||||||
sizeof(nva) / sizeof(nva[0]), NULL, req);
|
sizeof(nva) / sizeof(nva[0]), NULL, req);
|
||||||
|
|
|
@ -2339,8 +2339,8 @@ NGHTTP2_EXTERN int nghttp2_session_send(nghttp2_session *session);
|
||||||
* buffer up small chunks of data as necessary to avoid this
|
* buffer up small chunks of data as necessary to avoid this
|
||||||
* situation.
|
* situation.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN ssize_t nghttp2_session_mem_send(nghttp2_session *session,
|
NGHTTP2_EXTERN ssize_t
|
||||||
const uint8_t **data_ptr);
|
nghttp2_session_mem_send(nghttp2_session *session, const uint8_t **data_ptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2538,7 +2538,7 @@ nghttp2_session_set_stream_user_data(nghttp2_session *session,
|
||||||
* include the deferred DATA frames.
|
* include the deferred DATA frames.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN size_t
|
NGHTTP2_EXTERN size_t
|
||||||
nghttp2_session_get_outbound_queue_size(nghttp2_session *session);
|
nghttp2_session_get_outbound_queue_size(nghttp2_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2554,8 +2554,9 @@ NGHTTP2_EXTERN size_t
|
||||||
*
|
*
|
||||||
* This function returns -1 if it fails.
|
* This function returns -1 if it fails.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_recv_data_length(
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session *session, int32_t stream_id);
|
nghttp2_session_get_stream_effective_recv_data_length(nghttp2_session *session,
|
||||||
|
int32_t stream_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2567,8 +2568,9 @@ NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_recv_data_length(
|
||||||
*
|
*
|
||||||
* This function returns -1 if it fails.
|
* This function returns -1 if it fails.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_local_window_size(
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session *session, int32_t stream_id);
|
nghttp2_session_get_stream_effective_local_window_size(nghttp2_session *session,
|
||||||
|
int32_t stream_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2585,7 +2587,7 @@ NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_local_window_size(
|
||||||
* This function returns -1 if it fails.
|
* This function returns -1 if it fails.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session_get_effective_recv_data_length(nghttp2_session *session);
|
nghttp2_session_get_effective_recv_data_length(nghttp2_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2598,7 +2600,7 @@ NGHTTP2_EXTERN int32_t
|
||||||
* This function returns -1 if it fails.
|
* This function returns -1 if it fails.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session_get_effective_local_window_size(nghttp2_session *session);
|
nghttp2_session_get_effective_local_window_size(nghttp2_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2615,8 +2617,8 @@ NGHTTP2_EXTERN int32_t
|
||||||
* This function returns -1 if it fails.
|
* This function returns -1 if it fails.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session_get_stream_remote_window_size(nghttp2_session *session,
|
nghttp2_session_get_stream_remote_window_size(nghttp2_session *session,
|
||||||
int32_t stream_id);
|
int32_t stream_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2626,7 +2628,7 @@ NGHTTP2_EXTERN int32_t
|
||||||
* This function always succeeds.
|
* This function always succeeds.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session_get_remote_window_size(nghttp2_session *session);
|
nghttp2_session_get_remote_window_size(nghttp2_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2752,8 +2754,8 @@ NGHTTP2_EXTERN int nghttp2_submit_shutdown_notice(nghttp2_session *session);
|
||||||
* :enum:`nghttp2_settings_id`.
|
* :enum:`nghttp2_settings_id`.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN uint32_t
|
NGHTTP2_EXTERN uint32_t
|
||||||
nghttp2_session_get_remote_settings(nghttp2_session *session,
|
nghttp2_session_get_remote_settings(nghttp2_session *session,
|
||||||
nghttp2_settings_id id);
|
nghttp2_settings_id id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2782,7 +2784,7 @@ NGHTTP2_EXTERN int nghttp2_session_set_next_stream_id(nghttp2_session *session,
|
||||||
* function returns 1 << 31.
|
* function returns 1 << 31.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN uint32_t
|
NGHTTP2_EXTERN uint32_t
|
||||||
nghttp2_session_get_next_stream_id(nghttp2_session *session);
|
nghttp2_session_get_next_stream_id(nghttp2_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -2970,8 +2972,8 @@ NGHTTP2_EXTERN int nghttp2_session_upgrade2(nghttp2_session *session,
|
||||||
* The provided |buflen| size is too small to hold the output.
|
* The provided |buflen| size is too small to hold the output.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN ssize_t
|
NGHTTP2_EXTERN ssize_t
|
||||||
nghttp2_pack_settings_payload(uint8_t *buf, size_t buflen,
|
nghttp2_pack_settings_payload(uint8_t *buf, size_t buflen,
|
||||||
const nghttp2_settings_entry *iv, size_t niv);
|
const nghttp2_settings_entry *iv, size_t niv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -3082,11 +3084,11 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_submit_request(nghttp2_session *session,
|
nghttp2_submit_request(nghttp2_session *session,
|
||||||
const nghttp2_priority_spec *pri_spec,
|
const nghttp2_priority_spec *pri_spec,
|
||||||
const nghttp2_nv *nva, size_t nvlen,
|
const nghttp2_nv *nva, size_t nvlen,
|
||||||
const nghttp2_data_provider *data_prd,
|
const nghttp2_data_provider *data_prd,
|
||||||
void *stream_user_data);
|
void *stream_user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -3297,11 +3299,10 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session,
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
|
nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
|
||||||
int32_t stream_id,
|
int32_t stream_id, const nghttp2_priority_spec *pri_spec,
|
||||||
const nghttp2_priority_spec *pri_spec,
|
const nghttp2_nv *nva, size_t nvlen,
|
||||||
const nghttp2_nv *nva, size_t nvlen,
|
void *stream_user_data);
|
||||||
void *stream_user_data);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -3504,9 +3505,9 @@ NGHTTP2_EXTERN int nghttp2_submit_settings(nghttp2_session *session,
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
|
nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
|
||||||
int32_t stream_id, const nghttp2_nv *nva,
|
int32_t stream_id, const nghttp2_nv *nva,
|
||||||
size_t nvlen, void *promised_stream_user_data);
|
size_t nvlen, void *promised_stream_user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -3595,7 +3596,7 @@ NGHTTP2_EXTERN int nghttp2_submit_goaway(nghttp2_session *session,
|
||||||
* This function always succeeds.
|
* This function always succeeds.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_session_get_last_proc_stream_id(nghttp2_session *session);
|
nghttp2_session_get_last_proc_stream_id(nghttp2_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -3880,8 +3881,8 @@ nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater,
|
||||||
* The provided |buflen| size is too small to hold the output.
|
* The provided |buflen| size is too small to hold the output.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN ssize_t
|
NGHTTP2_EXTERN ssize_t
|
||||||
nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, uint8_t *buf,
|
nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, uint8_t *buf,
|
||||||
size_t buflen, const nghttp2_nv *nva, size_t nvlen);
|
size_t buflen, const nghttp2_nv *nva, size_t nvlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -4239,7 +4240,7 @@ typedef enum {
|
||||||
* :enum:`NGHTTP2_STREAM_STATE_IDLE`.
|
* :enum:`NGHTTP2_STREAM_STATE_IDLE`.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN nghttp2_stream_proto_state
|
NGHTTP2_EXTERN nghttp2_stream_proto_state
|
||||||
nghttp2_stream_get_state(nghttp2_stream *stream);
|
nghttp2_stream_get_state(nghttp2_stream *stream);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -4302,7 +4303,7 @@ NGHTTP2_EXTERN int32_t nghttp2_stream_get_weight(nghttp2_stream *stream);
|
||||||
* Returns the sum of the weight for |stream|'s children.
|
* Returns the sum of the weight for |stream|'s children.
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream);
|
nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#define lstreq(A, B, N) ((sizeof((A)) - 1) == (N) && memcmp((A), (B), (N)) == 0)
|
#define lstreq(A, B, N) ((sizeof((A)) - 1) == (N) && memcmp((A), (B), (N)) == 0)
|
||||||
|
|
||||||
#define nghttp2_struct_of(ptr, type, member) \
|
#define nghttp2_struct_of(ptr, type, member) \
|
||||||
((type *)(void *)((char *)(ptr) - offsetof(type, member)))
|
((type *)(void *)((char *)(ptr)-offsetof(type, member)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies 2 byte unsigned integer |n| in host byte order to |buf| in
|
* Copies 2 byte unsigned integer |n| in host byte order to |buf| in
|
||||||
|
|
|
@ -610,10 +610,9 @@ void nghttp2_session_del(nghttp2_session *session) {
|
||||||
nghttp2_mem_free(mem, session);
|
nghttp2_mem_free(mem, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int nghttp2_session_reprioritize_stream(
|
||||||
nghttp2_session_reprioritize_stream(nghttp2_session *session,
|
nghttp2_session *session, nghttp2_stream *stream,
|
||||||
nghttp2_stream *stream,
|
const nghttp2_priority_spec *pri_spec_in) {
|
||||||
const nghttp2_priority_spec *pri_spec_in) {
|
|
||||||
int rv;
|
int rv;
|
||||||
nghttp2_stream *dep_stream = NULL;
|
nghttp2_stream *dep_stream = NULL;
|
||||||
nghttp2_priority_spec pri_spec_default;
|
nghttp2_priority_spec pri_spec_default;
|
||||||
|
|
|
@ -59,13 +59,13 @@ void session_impl::start_resolve(const std::string &host,
|
||||||
resolver_.async_resolve({host, service},
|
resolver_.async_resolve({host, service},
|
||||||
[this](const boost::system::error_code &ec,
|
[this](const boost::system::error_code &ec,
|
||||||
tcp::resolver::iterator endpoint_it) {
|
tcp::resolver::iterator endpoint_it) {
|
||||||
if (ec) {
|
if (ec) {
|
||||||
not_connected(ec);
|
not_connected(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_connect(endpoint_it);
|
start_connect(endpoint_it);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::connected(tcp::resolver::iterator endpoint_it) {
|
void session_impl::connected(tcp::resolver::iterator endpoint_it) {
|
||||||
|
@ -462,9 +462,9 @@ const request *session_impl::submit(boost::system::error_code &ec,
|
||||||
[](nghttp2_session *session, int32_t stream_id, uint8_t *buf,
|
[](nghttp2_session *session, int32_t stream_id, uint8_t *buf,
|
||||||
size_t length, uint32_t *data_flags, nghttp2_data_source *source,
|
size_t length, uint32_t *data_flags, nghttp2_data_source *source,
|
||||||
void *user_data) -> ssize_t {
|
void *user_data) -> ssize_t {
|
||||||
auto strm = static_cast<stream *>(source->ptr);
|
auto strm = static_cast<stream *>(source->ptr);
|
||||||
return strm->request().impl().call_on_read(buf, length, data_flags);
|
return strm->request().impl().call_on_read(buf, length, data_flags);
|
||||||
};
|
};
|
||||||
prdptr = &prd;
|
prdptr = &prd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,13 @@ void session_tcp_impl::start_connect(tcp::resolver::iterator endpoint_it) {
|
||||||
boost::asio::async_connect(socket_, endpoint_it,
|
boost::asio::async_connect(socket_, endpoint_it,
|
||||||
[this](const boost::system::error_code &ec,
|
[this](const boost::system::error_code &ec,
|
||||||
tcp::resolver::iterator endpoint_it) {
|
tcp::resolver::iterator endpoint_it) {
|
||||||
if (ec) {
|
if (ec) {
|
||||||
not_connected(ec);
|
not_connected(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connected(endpoint_it);
|
connected(endpoint_it);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp::socket &session_tcp_impl::socket() { return socket_; }
|
tcp::socket &session_tcp_impl::socket() { return socket_; }
|
||||||
|
|
|
@ -45,31 +45,31 @@ session_tls_impl::session_tls_impl(boost::asio::io_service &io_service,
|
||||||
session_tls_impl::~session_tls_impl() {}
|
session_tls_impl::~session_tls_impl() {}
|
||||||
|
|
||||||
void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
|
void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
|
||||||
boost::asio::async_connect(socket(), endpoint_it,
|
boost::asio::async_connect(
|
||||||
[this](const boost::system::error_code &ec,
|
socket(), endpoint_it, [this](const boost::system::error_code &ec,
|
||||||
tcp::resolver::iterator endpoint_it) {
|
tcp::resolver::iterator endpoint_it) {
|
||||||
if (ec) {
|
if (ec) {
|
||||||
not_connected(ec);
|
not_connected(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_.async_handshake(
|
socket_.async_handshake(
|
||||||
boost::asio::ssl::stream_base::client,
|
boost::asio::ssl::stream_base::client,
|
||||||
[this, endpoint_it](const boost::system::error_code &ec) {
|
[this, endpoint_it](const boost::system::error_code &ec) {
|
||||||
if (ec) {
|
if (ec) {
|
||||||
not_connected(ec);
|
not_connected(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tls_h2_negotiated(socket_)) {
|
if (!tls_h2_negotiated(socket_)) {
|
||||||
not_connected(
|
not_connected(make_error_code(
|
||||||
make_error_code(NGHTTP2_ASIO_ERR_TLS_NO_APP_PROTO_NEGOTIATED));
|
NGHTTP2_ASIO_ERR_TLS_NO_APP_PROTO_NEGOTIATED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connected(endpoint_it);
|
connected(endpoint_it);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp::socket &session_tls_impl::socket() { return socket_.next_layer(); }
|
tcp::socket &session_tls_impl::socket() { return socket_.next_layer(); }
|
||||||
|
|
|
@ -90,8 +90,9 @@ generator_cb string_generator(std::string data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
generator_cb deferred_generator() {
|
generator_cb deferred_generator() {
|
||||||
return [](uint8_t *buf, size_t len,
|
return [](uint8_t *buf, size_t len, uint32_t *data_flags) {
|
||||||
uint32_t *data_flags) { return NGHTTP2_ERR_DEFERRED; };
|
return NGHTTP2_ERR_DEFERRED;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename F, typename... T>
|
template <typename F, typename... T>
|
||||||
|
@ -114,20 +115,20 @@ generator_cb file_generator_from_fd(int fd) {
|
||||||
|
|
||||||
return [fd, d](uint8_t *buf, size_t len, uint32_t *data_flags)
|
return [fd, d](uint8_t *buf, size_t len, uint32_t *data_flags)
|
||||||
-> generator_cb::result_type {
|
-> generator_cb::result_type {
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
while ((n = read(fd, buf, len)) == -1 && errno == EINTR)
|
while ((n = read(fd, buf, len)) == -1 && errno == EINTR)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
|
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_path(const std::string &path) { return util::check_path(path); }
|
bool check_path(const std::string &path) { return util::check_path(path); }
|
||||||
|
|
|
@ -123,44 +123,46 @@ void server::start_accept(boost::asio::ssl::context &tls_context,
|
||||||
auto new_connection = std::make_shared<connection<ssl_socket>>(
|
auto new_connection = std::make_shared<connection<ssl_socket>>(
|
||||||
mux, io_service_pool_.get_io_service(), tls_context);
|
mux, io_service_pool_.get_io_service(), tls_context);
|
||||||
|
|
||||||
acceptor.async_accept(new_connection->socket().lowest_layer(),
|
acceptor.async_accept(
|
||||||
[this, &tls_context, &acceptor, &mux, new_connection](
|
new_connection->socket().lowest_layer(),
|
||||||
const boost::system::error_code &e) {
|
[this, &tls_context, &acceptor, &mux, new_connection](
|
||||||
if (!e) {
|
const boost::system::error_code &e) {
|
||||||
new_connection->socket().lowest_layer().set_option(tcp::no_delay(true));
|
if (!e) {
|
||||||
new_connection->socket().async_handshake(
|
new_connection->socket().lowest_layer().set_option(
|
||||||
boost::asio::ssl::stream_base::server,
|
tcp::no_delay(true));
|
||||||
[new_connection](const boost::system::error_code &e) {
|
new_connection->socket().async_handshake(
|
||||||
if (e) {
|
boost::asio::ssl::stream_base::server,
|
||||||
return;
|
[new_connection](const boost::system::error_code &e) {
|
||||||
}
|
if (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tls_h2_negotiated(new_connection->socket())) {
|
if (!tls_h2_negotiated(new_connection->socket())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_connection->start();
|
new_connection->start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
start_accept(tls_context, acceptor, mux);
|
start_accept(tls_context, acceptor, mux);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::start_accept(tcp::acceptor &acceptor, serve_mux &mux) {
|
void server::start_accept(tcp::acceptor &acceptor, serve_mux &mux) {
|
||||||
auto new_connection = std::make_shared<connection<tcp::socket>>(
|
auto new_connection = std::make_shared<connection<tcp::socket>>(
|
||||||
mux, io_service_pool_.get_io_service());
|
mux, io_service_pool_.get_io_service());
|
||||||
|
|
||||||
acceptor.async_accept(new_connection->socket(),
|
acceptor.async_accept(
|
||||||
[this, &acceptor, &mux, new_connection](
|
new_connection->socket(), [this, &acceptor, &mux, new_connection](
|
||||||
const boost::system::error_code &e) {
|
const boost::system::error_code &e) {
|
||||||
if (!e) {
|
if (!e) {
|
||||||
new_connection->socket().set_option(tcp::no_delay(true));
|
new_connection->socket().set_option(tcp::no_delay(true));
|
||||||
new_connection->start();
|
new_connection->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
start_accept(acceptor, mux);
|
start_accept(acceptor, mux);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::stop() { io_service_pool_.stop(); }
|
void server::stop() { io_service_pool_.stop(); }
|
||||||
|
|
|
@ -83,29 +83,30 @@ public:
|
||||||
void do_read() {
|
void do_read() {
|
||||||
auto self = this->shared_from_this();
|
auto self = this->shared_from_this();
|
||||||
|
|
||||||
socket_.async_read_some(boost::asio::buffer(buffer_),
|
socket_.async_read_some(
|
||||||
[this, self](const boost::system::error_code &e,
|
boost::asio::buffer(buffer_),
|
||||||
std::size_t bytes_transferred) {
|
[this, self](const boost::system::error_code &e,
|
||||||
if (!e) {
|
std::size_t bytes_transferred) {
|
||||||
if (handler_->on_read(buffer_, bytes_transferred) != 0) {
|
if (!e) {
|
||||||
return;
|
if (handler_->on_read(buffer_, bytes_transferred) != 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
do_write();
|
do_write();
|
||||||
|
|
||||||
if (!writing_ && handler_->should_stop()) {
|
if (!writing_ && handler_->should_stop()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_read();
|
do_read();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an error occurs then no new asynchronous operations are
|
// If an error occurs then no new asynchronous operations are
|
||||||
// started. This means that all shared_ptr references to the
|
// started. This means that all shared_ptr references to the
|
||||||
// connection object will disappear and the object will be
|
// connection object will disappear and the object will be
|
||||||
// destroyed automatically after this handler returns. The
|
// destroyed automatically after this handler returns. The
|
||||||
// connection class's destructor closes the socket.
|
// connection class's destructor closes the socket.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_write() {
|
void do_write() {
|
||||||
|
|
|
@ -332,9 +332,9 @@ int http2_handler::start_response(stream &strm) {
|
||||||
[](nghttp2_session *session, int32_t stream_id, uint8_t *buf,
|
[](nghttp2_session *session, int32_t stream_id, uint8_t *buf,
|
||||||
size_t length, uint32_t *data_flags, nghttp2_data_source *source,
|
size_t length, uint32_t *data_flags, nghttp2_data_source *source,
|
||||||
void *user_data) -> ssize_t {
|
void *user_data) -> ssize_t {
|
||||||
auto &strm = *static_cast<stream *>(source->ptr);
|
auto &strm = *static_cast<stream *>(source->ptr);
|
||||||
return strm.response().impl().call_read(buf, length, data_flags);
|
return strm.response().impl().call_read(buf, length, data_flags);
|
||||||
};
|
};
|
||||||
prd_ptr = &prd;
|
prd_ptr = &prd;
|
||||||
}
|
}
|
||||||
rv = nghttp2_submit_response(session_, strm.get_stream_id(), nva.data(),
|
rv = nghttp2_submit_response(session_, strm.get_stream_id(), nva.data(),
|
||||||
|
|
10
src/http2.h
10
src/http2.h
|
@ -119,20 +119,20 @@ nghttp2_nv make_nv_nocopy(const std::string &name, const std::string &value,
|
||||||
|
|
||||||
// Create nghttp2_nv from string literal |name| and |value|.
|
// Create nghttp2_nv from string literal |name| and |value|.
|
||||||
template <size_t N, size_t M>
|
template <size_t N, size_t M>
|
||||||
constexpr nghttp2_nv make_nv_ll(const char (&name)[N], const char (&value)[M]) {
|
constexpr nghttp2_nv make_nv_ll(const char(&name)[N], const char(&value)[M]) {
|
||||||
return {(uint8_t *)name, (uint8_t *)value, N - 1, M - 1,
|
return {(uint8_t *)name, (uint8_t *)value, N - 1, M - 1,
|
||||||
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
|
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create nghttp2_nv from string literal |name| and c-string |value|.
|
// Create nghttp2_nv from string literal |name| and c-string |value|.
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
nghttp2_nv make_nv_lc(const char (&name)[N], const char *value) {
|
nghttp2_nv make_nv_lc(const char(&name)[N], const char *value) {
|
||||||
return {(uint8_t *)name, (uint8_t *)value, N - 1, strlen(value),
|
return {(uint8_t *)name, (uint8_t *)value, N - 1, strlen(value),
|
||||||
NGHTTP2_NV_FLAG_NO_COPY_NAME};
|
NGHTTP2_NV_FLAG_NO_COPY_NAME};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
nghttp2_nv make_nv_lc_nocopy(const char (&name)[N], const char *value) {
|
nghttp2_nv make_nv_lc_nocopy(const char(&name)[N], const char *value) {
|
||||||
return {(uint8_t *)name, (uint8_t *)value, N - 1, strlen(value),
|
return {(uint8_t *)name, (uint8_t *)value, N - 1, strlen(value),
|
||||||
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
|
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
|
||||||
}
|
}
|
||||||
|
@ -140,13 +140,13 @@ nghttp2_nv make_nv_lc_nocopy(const char (&name)[N], const char *value) {
|
||||||
// Create nghttp2_nv from string literal |name| and std::string
|
// Create nghttp2_nv from string literal |name| and std::string
|
||||||
// |value|.
|
// |value|.
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
nghttp2_nv make_nv_ls(const char (&name)[N], const std::string &value) {
|
nghttp2_nv make_nv_ls(const char(&name)[N], const std::string &value) {
|
||||||
return {(uint8_t *)name, (uint8_t *)value.c_str(), N - 1, value.size(),
|
return {(uint8_t *)name, (uint8_t *)value.c_str(), N - 1, value.size(),
|
||||||
NGHTTP2_NV_FLAG_NO_COPY_NAME};
|
NGHTTP2_NV_FLAG_NO_COPY_NAME};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
nghttp2_nv make_nv_ls_nocopy(const char (&name)[N], const std::string &value) {
|
nghttp2_nv make_nv_ls_nocopy(const char(&name)[N], const std::string &value) {
|
||||||
return {(uint8_t *)name, (uint8_t *)value.c_str(), N - 1, value.size(),
|
return {(uint8_t *)name, (uint8_t *)value.c_str(), N - 1, value.size(),
|
||||||
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
|
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,8 @@ typedef std::function<void(uint32_t)> close_cb;
|
||||||
// are not available right now, return NGHTTP2_ERR_DEFERRED. In case
|
// are not available right now, return NGHTTP2_ERR_DEFERRED. In case
|
||||||
// of the error and request/response must be closed, return
|
// of the error and request/response must be closed, return
|
||||||
// NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE.
|
// NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE.
|
||||||
typedef std::function<
|
typedef std::function<ssize_t(uint8_t *buf, std::size_t len,
|
||||||
ssize_t(uint8_t *buf, std::size_t len, uint32_t *data_flags)> generator_cb;
|
uint32_t *data_flags)> generator_cb;
|
||||||
|
|
||||||
// Convenient function to create function to read file denoted by
|
// Convenient function to create function to read file denoted by
|
||||||
// |path|. This can be passed to response::end().
|
// |path|. This can be passed to response::end().
|
||||||
|
|
|
@ -161,7 +161,7 @@ template <typename Memchunk> struct Memchunks {
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
template <size_t N> size_t append(const char (&s)[N]) {
|
template <size_t N> size_t append(const char(&s)[N]) {
|
||||||
return append(s, N - 1);
|
return append(s, N - 1);
|
||||||
}
|
}
|
||||||
size_t append(const std::string &s) { return append(s.c_str(), s.size()); }
|
size_t append(const std::string &s) { return append(s.c_str(), s.size()); }
|
||||||
|
|
|
@ -226,8 +226,7 @@ void test_peek_memchunks_append(void) {
|
||||||
|
|
||||||
std::array<uint8_t, 32> b{{
|
std::array<uint8_t, 32> b{{
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
||||||
'5', '6', '7', '8', '9', '0', '1',
|
'5', '6', '7', '8', '9', '0', '1', }},
|
||||||
}},
|
|
||||||
d;
|
d;
|
||||||
|
|
||||||
pchunks.append(b.data(), b.size());
|
pchunks.append(b.data(), b.size());
|
||||||
|
@ -261,8 +260,7 @@ void test_peek_memchunks_disable_peek_drain(void) {
|
||||||
|
|
||||||
std::array<uint8_t, 32> b{{
|
std::array<uint8_t, 32> b{{
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
||||||
'5', '6', '7', '8', '9', '0', '1',
|
'5', '6', '7', '8', '9', '0', '1', }},
|
||||||
}},
|
|
||||||
d;
|
d;
|
||||||
|
|
||||||
pchunks.append(b.data(), b.size());
|
pchunks.append(b.data(), b.size());
|
||||||
|
@ -289,8 +287,7 @@ void test_peek_memchunks_disable_peek_no_drain(void) {
|
||||||
|
|
||||||
std::array<uint8_t, 32> b{{
|
std::array<uint8_t, 32> b{{
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
||||||
'5', '6', '7', '8', '9', '0', '1',
|
'5', '6', '7', '8', '9', '0', '1', }},
|
||||||
}},
|
|
||||||
d;
|
d;
|
||||||
|
|
||||||
pchunks.append(b.data(), b.size());
|
pchunks.append(b.data(), b.size());
|
||||||
|
@ -317,8 +314,7 @@ void test_peek_memchunks_reset(void) {
|
||||||
|
|
||||||
std::array<uint8_t, 32> b{{
|
std::array<uint8_t, 32> b{{
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
|
||||||
'5', '6', '7', '8', '9', '0', '1',
|
'5', '6', '7', '8', '9', '0', '1', }},
|
||||||
}},
|
|
||||||
d;
|
d;
|
||||||
|
|
||||||
pchunks.append(b.data(), b.size());
|
pchunks.append(b.data(), b.size());
|
||||||
|
|
|
@ -89,8 +89,7 @@ enum {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr auto anchors = std::array<Anchor, 5>{{
|
constexpr auto anchors = std::array<Anchor, 5>{{
|
||||||
{3, 0, 201}, {5, 0, 101}, {7, 0, 1}, {9, 7, 1}, {11, 3, 1},
|
{3, 0, 201}, {5, 0, 101}, {7, 0, 1}, {9, 7, 1}, {11, 3, 1}, }};
|
||||||
}};
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Config::Config()
|
Config::Config()
|
||||||
|
@ -554,10 +553,11 @@ int HttpClient::initiate_connection() {
|
||||||
// If the user overrode the :authority or host header, use that
|
// If the user overrode the :authority or host header, use that
|
||||||
// value for the SNI extension
|
// value for the SNI extension
|
||||||
const char *host_string = nullptr;
|
const char *host_string = nullptr;
|
||||||
auto i = std::find_if(std::begin(config.headers),
|
auto i =
|
||||||
std::end(config.headers), [](const Header &nv) {
|
std::find_if(std::begin(config.headers), std::end(config.headers),
|
||||||
return ":authority" == nv.name || "host" == nv.name;
|
[](const Header &nv) {
|
||||||
});
|
return ":authority" == nv.name || "host" == nv.name;
|
||||||
|
});
|
||||||
if (i != std::end(config.headers)) {
|
if (i != std::end(config.headers)) {
|
||||||
host_string = (*i).value.c_str();
|
host_string = (*i).value.c_str();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1933,12 +1933,12 @@ void print_stats(const HttpClient &client) {
|
||||||
|
|
||||||
std::sort(std::begin(reqs), std::end(reqs),
|
std::sort(std::begin(reqs), std::end(reqs),
|
||||||
[](const Request *lhs, const Request *rhs) {
|
[](const Request *lhs, const Request *rhs) {
|
||||||
const auto <iming = lhs->timing;
|
const auto <iming = lhs->timing;
|
||||||
const auto &rtiming = rhs->timing;
|
const auto &rtiming = rhs->timing;
|
||||||
return ltiming.response_end_time < rtiming.response_end_time ||
|
return ltiming.response_end_time < rtiming.response_end_time ||
|
||||||
(ltiming.response_end_time == rtiming.response_end_time &&
|
(ltiming.response_end_time == rtiming.response_end_time &&
|
||||||
ltiming.request_start_time < rtiming.request_start_time);
|
ltiming.request_start_time < rtiming.request_start_time);
|
||||||
});
|
});
|
||||||
|
|
||||||
std::cout << R"(
|
std::cout << R"(
|
||||||
Request timing:
|
Request timing:
|
||||||
|
@ -2027,7 +2027,8 @@ namespace {
|
||||||
int communicate(
|
int communicate(
|
||||||
const std::string &scheme, const std::string &host, uint16_t port,
|
const std::string &scheme, const std::string &host, uint16_t port,
|
||||||
std::vector<std::tuple<std::string, nghttp2_data_provider *, int64_t>>
|
std::vector<std::tuple<std::string, nghttp2_data_provider *, int64_t>>
|
||||||
requests, const nghttp2_session_callbacks *callbacks) {
|
requests,
|
||||||
|
const nghttp2_session_callbacks *callbacks) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
auto loop = EV_DEFAULT;
|
auto loop = EV_DEFAULT;
|
||||||
SSL_CTX *ssl_ctx = nullptr;
|
SSL_CTX *ssl_ctx = nullptr;
|
||||||
|
|
|
@ -175,12 +175,12 @@ int ConnectionHandler::create_single_worker() {
|
||||||
,
|
,
|
||||||
nb_.get()
|
nb_.get()
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
);
|
);
|
||||||
auto cl_ssl_ctx = ssl::setup_client_ssl_context(
|
auto cl_ssl_ctx = ssl::setup_client_ssl_context(
|
||||||
#ifdef HAVE_NEVERBLEED
|
#ifdef HAVE_NEVERBLEED
|
||||||
nb_.get()
|
nb_.get()
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
);
|
);
|
||||||
|
|
||||||
if (cl_ssl_ctx) {
|
if (cl_ssl_ctx) {
|
||||||
all_ssl_ctx_.push_back(cl_ssl_ctx);
|
all_ssl_ctx_.push_back(cl_ssl_ctx);
|
||||||
|
@ -207,12 +207,12 @@ int ConnectionHandler::create_worker_thread(size_t num) {
|
||||||
,
|
,
|
||||||
nb_.get()
|
nb_.get()
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
);
|
);
|
||||||
auto cl_ssl_ctx = ssl::setup_client_ssl_context(
|
auto cl_ssl_ctx = ssl::setup_client_ssl_context(
|
||||||
#ifdef HAVE_NEVERBLEED
|
#ifdef HAVE_NEVERBLEED
|
||||||
nb_.get()
|
nb_.get()
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
);
|
);
|
||||||
|
|
||||||
if (cl_ssl_ctx) {
|
if (cl_ssl_ctx) {
|
||||||
all_ssl_ctx_.push_back(cl_ssl_ctx);
|
all_ssl_ctx_.push_back(cl_ssl_ctx);
|
||||||
|
@ -401,8 +401,8 @@ void ConnectionHandler::accept_pending_connection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ConnectionHandler::set_ticket_keys(
|
||||||
ConnectionHandler::set_ticket_keys(std::shared_ptr<TicketKeys> ticket_keys) {
|
std::shared_ptr<TicketKeys> ticket_keys) {
|
||||||
ticket_keys_ = std::move(ticket_keys);
|
ticket_keys_ = std::move(ticket_keys);
|
||||||
if (single_worker_) {
|
if (single_worker_) {
|
||||||
single_worker_->set_ticket_keys(ticket_keys_);
|
single_worker_->set_ticket_keys(ticket_keys_);
|
||||||
|
@ -740,8 +740,8 @@ void ConnectionHandler::on_tls_ticket_key_get_success(
|
||||||
set_ticket_keys_to_worker(ticket_keys);
|
set_ticket_keys_to_worker(ticket_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ConnectionHandler::schedule_next_tls_ticket_key_memcached_get(
|
||||||
ConnectionHandler::schedule_next_tls_ticket_key_memcached_get(ev_timer *w) {
|
ev_timer *w) {
|
||||||
ev_timer_set(w, get_config()->tls_ticket_key_memcached_interval, 0.);
|
ev_timer_set(w, get_config()->tls_ticket_key_memcached_interval, 0.);
|
||||||
ev_timer_start(loop_, w);
|
ev_timer_start(loop_, w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,10 +120,10 @@ void test_downstream_crumble_request_cookie(void) {
|
||||||
Headers cookies;
|
Headers cookies;
|
||||||
std::transform(std::begin(nva), std::end(nva), std::back_inserter(cookies),
|
std::transform(std::begin(nva), std::end(nva), std::back_inserter(cookies),
|
||||||
[](const nghttp2_nv &nv) {
|
[](const nghttp2_nv &nv) {
|
||||||
return Header(std::string(nv.name, nv.name + nv.namelen),
|
return Header(std::string(nv.name, nv.name + nv.namelen),
|
||||||
std::string(nv.value, nv.value + nv.valuelen),
|
std::string(nv.value, nv.value + nv.valuelen),
|
||||||
nv.flags & NGHTTP2_NV_FLAG_NO_INDEX);
|
nv.flags & NGHTTP2_NV_FLAG_NO_INDEX);
|
||||||
});
|
});
|
||||||
|
|
||||||
Headers ans = {{"cookie", "alpha"},
|
Headers ans = {{"cookie", "alpha"},
|
||||||
{"cookie", "bravo"},
|
{"cookie", "bravo"},
|
||||||
|
|
|
@ -553,8 +553,8 @@ void Http2Session::add_downstream_connection(Http2DownstreamConnection *dconn) {
|
||||||
dconns_.append(dconn);
|
dconns_.append(dconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Http2Session::remove_downstream_connection(
|
||||||
Http2Session::remove_downstream_connection(Http2DownstreamConnection *dconn) {
|
Http2DownstreamConnection *dconn) {
|
||||||
dconns_.remove(dconn);
|
dconns_.remove(dconn);
|
||||||
dconn->detach_stream_data();
|
dconn->detach_stream_data();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1391,8 +1391,8 @@ int Http2Upstream::error_reply(Downstream *downstream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Http2Upstream::add_pending_downstream(
|
||||||
Http2Upstream::add_pending_downstream(std::unique_ptr<Downstream> downstream) {
|
std::unique_ptr<Downstream> downstream) {
|
||||||
downstream_queue_.add_pending(std::move(downstream));
|
downstream_queue_.add_pending(std::move(downstream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1670,9 +1670,8 @@ int Http2Upstream::consume(int32_t stream_id, size_t len) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Http2Upstream::log_response_headers(
|
||||||
Http2Upstream::log_response_headers(Downstream *downstream,
|
Downstream *downstream, const std::vector<nghttp2_nv> &nva) const {
|
||||||
const std::vector<nghttp2_nv> &nva) const {
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
for (auto &nv : nva) {
|
for (auto &nv : nva) {
|
||||||
ss << TTY_HTTP_HD << nv.name << TTY_RST << ": " << nv.value << "\n";
|
ss << TTY_HTTP_HD << nv.name << TTY_RST << ": " << nv.value << "\n";
|
||||||
|
|
|
@ -184,7 +184,7 @@ std::pair<OutputIterator, size_t> copy(const std::string &src, size_t avail,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template <size_t N, typename OutputIterator>
|
template <size_t N, typename OutputIterator>
|
||||||
std::pair<OutputIterator, size_t> copy_l(const char (&src)[N], size_t avail,
|
std::pair<OutputIterator, size_t> copy_l(const char(&src)[N], size_t avail,
|
||||||
OutputIterator oitr) {
|
OutputIterator oitr) {
|
||||||
return copy(src, N - 1, avail, oitr);
|
return copy(src, N - 1, avail, oitr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,8 @@ static LogConfig *config = new LogConfig();
|
||||||
LogConfig *log_config(void) { return config; }
|
LogConfig *log_config(void) { return config; }
|
||||||
#endif // NOTHREADS
|
#endif // NOTHREADS
|
||||||
|
|
||||||
void
|
void LogConfig::update_tstamp(
|
||||||
LogConfig::update_tstamp(const std::chrono::system_clock::time_point &now) {
|
const std::chrono::system_clock::time_point &now) {
|
||||||
auto t0 = std::chrono::system_clock::to_time_t(time_str_updated_);
|
auto t0 = std::chrono::system_clock::to_time_t(time_str_updated_);
|
||||||
auto t1 = std::chrono::system_clock::to_time_t(now);
|
auto t1 = std::chrono::system_clock::to_time_t(now);
|
||||||
if (t0 == t1) {
|
if (t0 == t1) {
|
||||||
|
|
|
@ -888,13 +888,11 @@ int SpdyUpstream::error_reply(Downstream *downstream,
|
||||||
|
|
||||||
std::string content_length = util::utos(html.size());
|
std::string content_length = util::utos(html.size());
|
||||||
std::string status_string = http2::get_status_string(status_code);
|
std::string status_string = http2::get_status_string(status_code);
|
||||||
const char *nv[] = {":status", status_string.c_str(),
|
const char *nv[] = {":status", status_string.c_str(), ":version", "http/1.1",
|
||||||
":version", "http/1.1",
|
"content-type", "text/html; charset=UTF-8", "server",
|
||||||
"content-type", "text/html; charset=UTF-8",
|
get_config()->server_name, "content-length",
|
||||||
"server", get_config()->server_name,
|
content_length.c_str(), "date",
|
||||||
"content-length", content_length.c_str(),
|
lgconf->time_http_str.c_str(), nullptr};
|
||||||
"date", lgconf->time_http_str.c_str(),
|
|
||||||
nullptr};
|
|
||||||
|
|
||||||
rv = spdylay_submit_response(session_, downstream->get_stream_id(), nv,
|
rv = spdylay_submit_response(session_, downstream->get_stream_id(), nv,
|
||||||
&data_prd);
|
&data_prd);
|
||||||
|
|
|
@ -1145,7 +1145,7 @@ SSL_CTX *setup_server_ssl_context(std::vector<SSL_CTX *> &all_ssl_ctx,
|
||||||
auto ssl_ctx = ssl::create_ssl_context(get_config()->private_key_file.get(),
|
auto ssl_ctx = ssl::create_ssl_context(get_config()->private_key_file.get(),
|
||||||
get_config()->cert_file.get()
|
get_config()->cert_file.get()
|
||||||
#ifdef HAVE_NEVERBLEED
|
#ifdef HAVE_NEVERBLEED
|
||||||
,
|
,
|
||||||
nb
|
nb
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
);
|
);
|
||||||
|
@ -1166,7 +1166,7 @@ SSL_CTX *setup_server_ssl_context(std::vector<SSL_CTX *> &all_ssl_ctx,
|
||||||
auto ssl_ctx =
|
auto ssl_ctx =
|
||||||
ssl::create_ssl_context(keycert.first.c_str(), keycert.second.c_str()
|
ssl::create_ssl_context(keycert.first.c_str(), keycert.second.c_str()
|
||||||
#ifdef HAVE_NEVERBLEED
|
#ifdef HAVE_NEVERBLEED
|
||||||
,
|
,
|
||||||
nb
|
nb
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,13 +43,12 @@ void test_shrpx_ssl_create_lookup_tree(void) {
|
||||||
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method()),
|
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method()),
|
||||||
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method())};
|
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method())};
|
||||||
|
|
||||||
const char *hostnames[] = {"example.com", "www.example.org",
|
const char *hostnames[] = {
|
||||||
"*www.example.org", "x*.host.domain",
|
"example.com", "www.example.org", "*www.example.org", "x*.host.domain",
|
||||||
"*yy.host.domain", "nghttp2.sourceforge.net",
|
"*yy.host.domain", "nghttp2.sourceforge.net", "sourceforge.net",
|
||||||
"sourceforge.net",
|
"sourceforge.net", // duplicate
|
||||||
"sourceforge.net", // duplicate
|
"*.foo.bar", // oo.bar is suffix of *.foo.bar
|
||||||
"*.foo.bar", // oo.bar is suffix of *.foo.bar
|
"oo.bar"};
|
||||||
"oo.bar"};
|
|
||||||
int num = array_size(ctxs);
|
int num = array_size(ctxs);
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
tree->add_cert(ctxs[i], hostnames[i], strlen(hostnames[i]));
|
tree->add_cert(ctxs[i], hostnames[i], strlen(hostnames[i]));
|
||||||
|
|
|
@ -60,11 +60,11 @@ make_array(T &&... t) {
|
||||||
sizeof...(T)>{{std::forward<T>(t)...}};
|
sizeof...(T)>{{std::forward<T>(t)...}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
|
template <typename T, size_t N> constexpr size_t array_size(T(&)[N]) {
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t N> constexpr size_t str_size(T (&)[N]) {
|
template <typename T, size_t N> constexpr size_t str_size(T(&)[N]) {
|
||||||
return N - 1;
|
return N - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ template <typename F, typename... T> struct Defer {
|
||||||
Defer(Defer &&o) : f(std::move(o.f)) {}
|
Defer(Defer &&o) : f(std::move(o.f)) {}
|
||||||
~Defer() { f(); }
|
~Defer() { f(); }
|
||||||
|
|
||||||
using ResultType = typename std::result_of<
|
using ResultType = typename std::result_of<typename std::decay<F>::type(
|
||||||
typename std::decay<F>::type(typename std::decay<T>::type...)>::type;
|
typename std::decay<T>::type...)>::type;
|
||||||
std::function<ResultType()> f;
|
std::function<ResultType()> f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
36
src/util.cc
36
src/util.cc
|
@ -433,15 +433,15 @@ std::string format_hex(const unsigned char *s, size_t len) {
|
||||||
void to_token68(std::string &base64str) {
|
void to_token68(std::string &base64str) {
|
||||||
std::transform(std::begin(base64str), std::end(base64str),
|
std::transform(std::begin(base64str), std::end(base64str),
|
||||||
std::begin(base64str), [](char c) {
|
std::begin(base64str), [](char c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '+':
|
case '+':
|
||||||
return '-';
|
return '-';
|
||||||
case '/':
|
case '/':
|
||||||
return '_';
|
return '_';
|
||||||
default:
|
default:
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
base64str.erase(std::find(std::begin(base64str), std::end(base64str), '='),
|
base64str.erase(std::find(std::begin(base64str), std::end(base64str), '='),
|
||||||
std::end(base64str));
|
std::end(base64str));
|
||||||
}
|
}
|
||||||
|
@ -449,15 +449,15 @@ void to_token68(std::string &base64str) {
|
||||||
void to_base64(std::string &token68str) {
|
void to_base64(std::string &token68str) {
|
||||||
std::transform(std::begin(token68str), std::end(token68str),
|
std::transform(std::begin(token68str), std::end(token68str),
|
||||||
std::begin(token68str), [](char c) {
|
std::begin(token68str), [](char c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
return '+';
|
return '+';
|
||||||
case '_':
|
case '_':
|
||||||
return '/';
|
return '/';
|
||||||
default:
|
default:
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (token68str.size() & 0x3) {
|
if (token68str.size() & 0x3) {
|
||||||
token68str.append(4 - (token68str.size() & 0x3), '=');
|
token68str.append(4 - (token68str.size() & 0x3), '=');
|
||||||
}
|
}
|
||||||
|
|
10
src/util.h
10
src/util.h
|
@ -220,7 +220,7 @@ std::string quote_string(const std::string &target);
|
||||||
|
|
||||||
std::string format_hex(const unsigned char *s, size_t len);
|
std::string format_hex(const unsigned char *s, size_t len);
|
||||||
|
|
||||||
template <size_t N> std::string format_hex(const unsigned char (&s)[N]) {
|
template <size_t N> std::string format_hex(const unsigned char(&s)[N]) {
|
||||||
return format_hex(s, N);
|
return format_hex(s, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,11 +366,11 @@ inline bool strieq(const char *a, const std::string &b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename InputIt, size_t N>
|
template <typename InputIt, size_t N>
|
||||||
bool strieq_l(const char (&a)[N], InputIt b, size_t blen) {
|
bool strieq_l(const char(&a)[N], InputIt b, size_t blen) {
|
||||||
return strieq(a, N - 1, b, blen);
|
return strieq(a, N - 1, b, blen);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N> bool strieq_l(const char (&a)[N], const std::string &b) {
|
template <size_t N> bool strieq_l(const char(&a)[N], const std::string &b) {
|
||||||
return strieq(a, N - 1, std::begin(b), b.size());
|
return strieq(a, N - 1, std::begin(b), b.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,11 +400,11 @@ inline bool streq(const char *a, const char *b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename InputIt, size_t N>
|
template <typename InputIt, size_t N>
|
||||||
bool streq_l(const char (&a)[N], InputIt b, size_t blen) {
|
bool streq_l(const char(&a)[N], InputIt b, size_t blen) {
|
||||||
return streq(a, N - 1, b, blen);
|
return streq(a, N - 1, b, blen);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N> bool streq_l(const char (&a)[N], const std::string &b) {
|
template <size_t N> bool streq_l(const char(&a)[N], const std::string &b) {
|
||||||
return streq(a, N - 1, std::begin(b), b.size());
|
return streq(a, N - 1, std::begin(b), b.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1007,25 +1007,20 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
nghttp2_hd_deflater deflater;
|
nghttp2_hd_deflater deflater;
|
||||||
nghttp2_hd_inflater inflater;
|
nghttp2_hd_inflater inflater;
|
||||||
nghttp2_nv nv1[] = {
|
nghttp2_nv nv1[] = {
|
||||||
MAKE_NV(":status", "200 OK"),
|
MAKE_NV(":status", "200 OK"), MAKE_NV("access-control-allow-origin", "*"),
|
||||||
MAKE_NV("access-control-allow-origin", "*"),
|
|
||||||
MAKE_NV("cache-control", "private, max-age=0, must-revalidate"),
|
MAKE_NV("cache-control", "private, max-age=0, must-revalidate"),
|
||||||
MAKE_NV("content-length", "76073"),
|
MAKE_NV("content-length", "76073"), MAKE_NV("content-type", "text/html"),
|
||||||
MAKE_NV("content-type", "text/html"),
|
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
MAKE_NV("expires", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("expires", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
MAKE_NV("server", "Apache"),
|
MAKE_NV("server", "Apache"), MAKE_NV("vary", "foobar"),
|
||||||
MAKE_NV("vary", "foobar"),
|
|
||||||
MAKE_NV("via", "1.1 alphabravo (squid/3.x.x), 1.1 nghttpx"),
|
MAKE_NV("via", "1.1 alphabravo (squid/3.x.x), 1.1 nghttpx"),
|
||||||
MAKE_NV("x-cache", "MISS from alphabravo"),
|
MAKE_NV("x-cache", "MISS from alphabravo"),
|
||||||
MAKE_NV("x-cache-action", "MISS"),
|
MAKE_NV("x-cache-action", "MISS"), MAKE_NV("x-cache-age", "0"),
|
||||||
MAKE_NV("x-cache-age", "0"),
|
|
||||||
MAKE_NV("x-cache-lookup", "MISS from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "MISS from alphabravo:3128"),
|
||||||
MAKE_NV("x-lb-nocache", "true"),
|
MAKE_NV("x-lb-nocache", "true"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv2[] = {
|
nghttp2_nv nv2[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=56682045"),
|
MAKE_NV("cache-control", "max-age=56682045"),
|
||||||
MAKE_NV("content-type", "text/css"),
|
MAKE_NV("content-type", "text/css"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1036,8 +1031,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache", "HIT from alphabravo"),
|
MAKE_NV("x-cache", "HIT from alphabravo"),
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128")};
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128")};
|
||||||
nghttp2_nv nv3[] = {
|
nghttp2_nv nv3[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=56682072"),
|
MAKE_NV("cache-control", "max-age=56682072"),
|
||||||
MAKE_NV("content-type", "text/css"),
|
MAKE_NV("content-type", "text/css"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1049,8 +1043,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv4[] = {
|
nghttp2_nv nv4[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=56682022"),
|
MAKE_NV("cache-control", "max-age=56682022"),
|
||||||
MAKE_NV("content-type", "text/css"),
|
MAKE_NV("content-type", "text/css"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1062,8 +1055,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv5[] = {
|
nghttp2_nv nv5[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=4461139"),
|
MAKE_NV("cache-control", "max-age=4461139"),
|
||||||
MAKE_NV("content-type", "application/x-javascript"),
|
MAKE_NV("content-type", "application/x-javascript"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1075,8 +1067,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv6[] = {
|
nghttp2_nv nv6[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=18645951"),
|
MAKE_NV("cache-control", "max-age=18645951"),
|
||||||
MAKE_NV("content-type", "application/x-javascript"),
|
MAKE_NV("content-type", "application/x-javascript"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1088,8 +1079,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv7[] = {
|
nghttp2_nv nv7[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=31536000"),
|
MAKE_NV("cache-control", "max-age=31536000"),
|
||||||
MAKE_NV("content-type", "application/javascript"),
|
MAKE_NV("content-type", "application/javascript"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1101,8 +1091,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv8[] = {
|
nghttp2_nv nv8[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=31536000"),
|
MAKE_NV("cache-control", "max-age=31536000"),
|
||||||
MAKE_NV("content-type", "application/javascript"),
|
MAKE_NV("content-type", "application/javascript"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1114,8 +1103,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv9[] = {
|
nghttp2_nv nv9[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=31536000"),
|
MAKE_NV("cache-control", "max-age=31536000"),
|
||||||
MAKE_NV("content-type", "application/javascript"),
|
MAKE_NV("content-type", "application/javascript"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
@ -1127,8 +1115,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||||
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
|
||||||
};
|
};
|
||||||
nghttp2_nv nv10[] = {
|
nghttp2_nv nv10[] = {
|
||||||
MAKE_NV(":status", "304 Not Modified"),
|
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
|
||||||
MAKE_NV("age", "0"),
|
|
||||||
MAKE_NV("cache-control", "max-age=56682045"),
|
MAKE_NV("cache-control", "max-age=56682045"),
|
||||||
MAKE_NV("content-type", "text/css"),
|
MAKE_NV("content-type", "text/css"),
|
||||||
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
|
||||||
|
|
|
@ -45,9 +45,7 @@ static string_entry *string_entry_new(const char *s) {
|
||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void string_entry_del(string_entry *ent) {
|
static void string_entry_del(string_entry *ent) { free(ent); }
|
||||||
free(ent);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int pq_less(const void *lhs, const void *rhs) {
|
static int pq_less(const void *lhs, const void *rhs) {
|
||||||
return strcmp(((string_entry *)lhs)->s, ((string_entry *)rhs)->s) < 0;
|
return strcmp(((string_entry *)lhs)->s, ((string_entry *)rhs)->s) < 0;
|
||||||
|
|
|
@ -8401,9 +8401,9 @@ void test_nghttp2_http_mandatory_headers(void) {
|
||||||
MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
|
MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
|
||||||
MAKE_NV("content-length", "-1")};
|
MAKE_NV("content-length", "-1")};
|
||||||
const nghttp2_nv dupcl_reqnv[] = {
|
const nghttp2_nv dupcl_reqnv[] = {
|
||||||
MAKE_NV(":scheme", "https"), MAKE_NV(":method", "POST"),
|
MAKE_NV(":scheme", "https"), MAKE_NV(":method", "POST"),
|
||||||
MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
|
MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
|
||||||
MAKE_NV("content-length", "0"), MAKE_NV("content-length", "0")};
|
MAKE_NV("content-length", "0"), MAKE_NV("content-length", "0")};
|
||||||
const nghttp2_nv badhd_reqnv[] = {
|
const nghttp2_nv badhd_reqnv[] = {
|
||||||
MAKE_NV(":scheme", "https"), MAKE_NV(":method", "GET"),
|
MAKE_NV(":scheme", "https"), MAKE_NV(":method", "GET"),
|
||||||
MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
|
MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
|
||||||
|
@ -8996,8 +8996,8 @@ void test_nghttp2_http_ignore_regular_header(void) {
|
||||||
my_user_data ud;
|
my_user_data ud;
|
||||||
const nghttp2_nv bad_reqnv[] = {
|
const nghttp2_nv bad_reqnv[] = {
|
||||||
MAKE_NV(":authority", "localhost"), MAKE_NV(":scheme", "https"),
|
MAKE_NV(":authority", "localhost"), MAKE_NV(":scheme", "https"),
|
||||||
MAKE_NV(":path", "/"), MAKE_NV(":method", "GET"),
|
MAKE_NV(":path", "/"), MAKE_NV(":method", "GET"),
|
||||||
MAKE_NV("foo", "\x0zzz"), MAKE_NV("bar", "buzz"),
|
MAKE_NV("foo", "\x0zzz"), MAKE_NV("bar", "buzz"),
|
||||||
};
|
};
|
||||||
const nghttp2_nv bad_ansnv[] = {
|
const nghttp2_nv bad_ansnv[] = {
|
||||||
MAKE_NV(":authority", "localhost"), MAKE_NV(":scheme", "https"),
|
MAKE_NV(":authority", "localhost"), MAKE_NV(":scheme", "https"),
|
||||||
|
|
Loading…
Reference in New Issue