diff options
Diffstat (limited to 'src/nghttp.cc')
-rw-r--r-- | src/nghttp.cc | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/src/nghttp.cc b/src/nghttp.cc index 41a88c6..f670320 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -157,7 +157,7 @@ std::string strip_fragment(const char *raw_uri) { } // namespace Request::Request(const std::string &uri, const http_parser_url &u, - const nghttp2_data_provider *data_prd, int64_t data_length, + const nghttp2_data_provider2 *data_prd, int64_t data_length, const nghttp2_priority_spec &pri_spec, int level) : uri(uri), u(u), @@ -370,11 +370,11 @@ void continue_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) { auto req = static_cast<Request *>(w->data); int error; - error = nghttp2_submit_data(client->session, NGHTTP2_FLAG_END_STREAM, - req->stream_id, req->data_prd); + error = nghttp2_submit_data2(client->session, NGHTTP2_FLAG_END_STREAM, + req->stream_id, req->data_prd); if (error) { - std::cerr << "[ERROR] nghttp2_submit_data() returned error: " + std::cerr << "[ERROR] nghttp2_submit_data2() returned error: " << nghttp2_strerror(error) << std::endl; nghttp2_submit_rst_stream(client->session, NGHTTP2_FLAG_NONE, req->stream_id, NGHTTP2_INTERNAL_ERROR); @@ -525,13 +525,13 @@ int submit_request(HttpClient *client, const Headers &headers, Request *req) { nva.data(), nva.size(), req); } else { stream_id = - nghttp2_submit_request(client->session, &req->pri_spec, nva.data(), - nva.size(), req->data_prd, req); + nghttp2_submit_request2(client->session, &req->pri_spec, nva.data(), + nva.size(), req->data_prd, req); } if (stream_id < 0) { std::cerr << "[ERROR] nghttp2_submit_" - << (expect_continue ? "headers" : "request") + << (expect_continue ? "headers" : "request2") << "() returned error: " << nghttp2_strerror(stream_id) << std::endl; return -1; @@ -953,14 +953,14 @@ size_t populate_settings(nghttp2_settings_entry *iv) { } // namespace int HttpClient::on_upgrade_connect() { - ssize_t rv; + nghttp2_ssize rv; record_connect_end_time(); assert(!reqvec.empty()); std::array<nghttp2_settings_entry, 16> iv; size_t niv = populate_settings(iv.data()); assert(settings_payload.size() >= 8 * niv); - rv = nghttp2_pack_settings_payload(settings_payload.data(), - settings_payload.size(), iv.data(), niv); + rv = nghttp2_pack_settings_payload2(settings_payload.data(), + settings_payload.size(), iv.data(), niv); if (rv < 0) { return -1; } @@ -1250,9 +1250,9 @@ int HttpClient::on_read(const uint8_t *data, size_t len) { util::hexdump(stdout, data, len); } - auto rv = nghttp2_session_mem_recv(session, data, len); + auto rv = nghttp2_session_mem_recv2(session, data, len); if (rv < 0) { - std::cerr << "[ERROR] nghttp2_session_mem_recv() returned error: " + std::cerr << "[ERROR] nghttp2_session_mem_recv2() returned error: " << nghttp2_strerror(rv) << std::endl; return -1; } @@ -1276,9 +1276,9 @@ int HttpClient::on_write() { } const uint8_t *data; - auto len = nghttp2_session_mem_send(session, &data); + auto len = nghttp2_session_mem_send2(session, &data); if (len < 0) { - std::cerr << "[ERROR] nghttp2_session_send() returned error: " + std::cerr << "[ERROR] nghttp2_session_send2() returned error: " << nghttp2_strerror(len) << std::endl; return -1; } @@ -1449,7 +1449,7 @@ void HttpClient::update_hostport() { } bool HttpClient::add_request(const std::string &uri, - const nghttp2_data_provider *data_prd, + const nghttp2_data_provider2 *data_prd, int64_t data_length, const nghttp2_priority_spec &pri_spec, int level) { http_parser_url u{}; @@ -1768,9 +1768,9 @@ int on_data_chunk_recv_callback(nghttp2_session *session, uint8_t flags, } // namespace namespace { -ssize_t select_padding_callback(nghttp2_session *session, - const nghttp2_frame *frame, size_t max_payload, - void *user_data) { +nghttp2_ssize select_padding_callback(nghttp2_session *session, + const nghttp2_frame *frame, + size_t max_payload, void *user_data) { return std::min(max_payload, frame->hd.length + config.padding); } } // namespace @@ -2241,7 +2241,7 @@ namespace { int communicate( const std::string &scheme, const std::string &host, uint16_t port, std::vector< - std::tuple<std::string, nghttp2_data_provider *, int64_t, int32_t>> + std::tuple<std::string, nghttp2_data_provider2 *, int64_t, int32_t>> requests, const nghttp2_session_callbacks *callbacks) { int result = 0; @@ -2311,6 +2311,17 @@ int communicate( auto proto_list = util::get_default_alpn(); SSL_CTX_set_alpn_protos(ssl_ctx, proto_list.data(), proto_list.size()); + +#if defined(NGHTTP2_OPENSSL_IS_BORINGSSL) && defined(HAVE_LIBBROTLI) + if (!SSL_CTX_add_cert_compression_alg( + ssl_ctx, nghttp2::tls::CERTIFICATE_COMPRESSION_ALGO_BROTLI, + nghttp2::tls::cert_compress, nghttp2::tls::cert_decompress)) { + std::cerr << "[ERROR] SSL_CTX_add_cert_compression_alg failed." + << std::endl; + result = -1; + goto fin; + } +#endif // NGHTTP2_OPENSSL_IS_BORINGSSL && HAVE_LIBBROTLI } { HttpClient client{callbacks, loop, ssl_ctx}; @@ -2391,9 +2402,10 @@ fin: } // namespace namespace { -ssize_t file_read_callback(nghttp2_session *session, int32_t stream_id, - uint8_t *buf, size_t length, uint32_t *data_flags, - nghttp2_data_source *source, void *user_data) { +nghttp2_ssize file_read_callback(nghttp2_session *session, int32_t stream_id, + uint8_t *buf, size_t length, + uint32_t *data_flags, + nghttp2_data_source *source, void *user_data) { int rv; auto req = static_cast<Request *>( nghttp2_session_get_stream_user_data(session, stream_id)); @@ -2429,14 +2441,14 @@ ssize_t file_read_callback(nghttp2_session *session, int32_t stream_id, } } - return nread; + return static_cast<nghttp2_ssize>(nread); } if (req->data_offset > req->data_length || nread == 0) { return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; } - return nread; + return static_cast<nghttp2_ssize>(nread); } } // namespace @@ -2480,7 +2492,7 @@ int run(char **uris, int n) { callbacks, on_frame_not_send_callback); if (config.padding) { - nghttp2_session_callbacks_set_select_padding_callback( + nghttp2_session_callbacks_set_select_padding_callback2( callbacks, select_padding_callback); } @@ -2489,7 +2501,7 @@ int run(char **uris, int n) { uint16_t prev_port = 0; int failures = 0; int data_fd = -1; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; struct stat data_stat; if (!config.datafile.empty()) { @@ -2557,7 +2569,7 @@ int run(char **uris, int n) { data_prd.read_callback = file_read_callback; } std::vector< - std::tuple<std::string, nghttp2_data_provider *, int64_t, int32_t>> + std::tuple<std::string, nghttp2_data_provider2 *, int64_t, int32_t>> requests; size_t next_weight_idx = 0; |