This commit is contained in:
Tatsuhiro Tsujikawa 2019-07-14 22:11:42 +09:00
parent 7cd5ed6fc6
commit 476e9d0a48
6 changed files with 30 additions and 28 deletions

View File

@ -16,20 +16,20 @@ An experimental high level C++ library is also available.
We have Python bindings of this library, but we do not have full We have Python bindings of this library, but we do not have full
code coverage yet. code coverage yet.
h2load IETF QUIC Running h2load against HTTP/3 endpoint
---------------- --------------------------------------
In order to build h2load with IETF QUIC, you have to build ngtcp2, In order to build h2load with HTTP/3 support, you have to build
nghttp3 and my patched OpenSSL. ngtcp2, nghttp3 and my patched OpenSSL.
https://github.com/ngtcp2/ngtcp2/tree/draft-20#build-from-git https://github.com/ngtcp2/ngtcp2/tree/draft-20#build-from-git
describes how to build these three software. describes how to build these three software.
To run h2load against IETF QUIC server, specify h3-20 ALPN with To run h2load against HTTP/3 server, specify h3-22 ALPN with
``--npn-list`` option like so: ``--npn-list`` option like so:
.. code-block:: text .. code-block:: text
$ h2load --npn-list h3-20 https://localhost:4433 $ h2load --npn-list h3-22 https://localhost:4433
Development Status Development Status
------------------ ------------------

View File

@ -482,8 +482,8 @@ struct Client {
size_t keylen, const uint8_t *sample, size_t samplelen); size_t keylen, const uint8_t *sample, size_t samplelen);
int quic_recv_stream_data(int64_t stream_id, int fin, const uint8_t *data, int quic_recv_stream_data(int64_t stream_id, int fin, const uint8_t *data,
size_t datalen); size_t datalen);
int quic_stream_close(int64_t stream_id, uint16_t app_error_code); int quic_stream_close(int64_t stream_id, uint64_t app_error_code);
int quic_stream_reset(int64_t stream_id, uint16_t app_error_code); int quic_stream_reset(int64_t stream_id, uint64_t app_error_code);
int quic_extend_max_local_streams(); int quic_extend_max_local_streams();
int quic_tls_handshake(bool initial = false); int quic_tls_handshake(bool initial = false);

View File

@ -76,7 +76,7 @@ int64_t Http3Session::submit_request_internal() {
return rv; return rv;
} }
rv = nghttp3_conn_submit_request(conn_, stream_id, nullptr, rv = nghttp3_conn_submit_request(conn_, stream_id,
reinterpret_cast<nghttp3_nv *>(nva.data()), reinterpret_cast<nghttp3_nv *>(nva.data()),
nva.size(), nullptr, nullptr); nva.size(), nullptr, nullptr);
if (rv != 0) { if (rv != 0) {
@ -105,18 +105,18 @@ size_t Http3Session::max_concurrent_streams() {
} }
namespace { namespace {
int stream_close(nghttp3_conn *conn, int64_t stream_id, uint16_t error_code, int stream_close(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code,
void *user_data, void *stream_user_data) { void *user_data, void *stream_user_data) {
auto s = static_cast<Http3Session *>(user_data); auto s = static_cast<Http3Session *>(user_data);
if (s->stream_close(stream_id, error_code) != 0) { if (s->stream_close(stream_id, app_error_code) != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE; return NGHTTP3_ERR_CALLBACK_FAILURE;
} }
return 0; return 0;
} }
} // namespace } // namespace
int Http3Session::stream_close(int64_t stream_id, uint16_t error_code) { int Http3Session::stream_close(int64_t stream_id, uint64_t app_error_code) {
client_->on_stream_close(stream_id, error_code == NGHTTP3_HTTP_NO_ERROR); client_->on_stream_close(stream_id, app_error_code == NGHTTP3_HTTP_NO_ERROR);
return 0; return 0;
} }
@ -186,19 +186,21 @@ void Http3Session::recv_header(int64_t stream_id, const nghttp3_vec *name,
} }
namespace { namespace {
int send_stop_sending(nghttp3_conn *conn, int64_t stream_id, void *user_data, int send_stop_sending(nghttp3_conn *conn, int64_t stream_id,
uint64_t app_error_code, void *user_data,
void *stream_user_data) { void *stream_user_data) {
auto s = static_cast<Http3Session *>(user_data); auto s = static_cast<Http3Session *>(user_data);
if (s->send_stop_sending(stream_id) != 0) { if (s->send_stop_sending(stream_id, app_error_code) != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE; return NGHTTP3_ERR_CALLBACK_FAILURE;
} }
return 0; return 0;
} }
} // namespace } // namespace
int Http3Session::send_stop_sending(int64_t stream_id) { int Http3Session::send_stop_sending(int64_t stream_id,
uint64_t app_error_code) {
auto rv = ngtcp2_conn_shutdown_stream_read(client_->quic.conn, stream_id, auto rv = ngtcp2_conn_shutdown_stream_read(client_->quic.conn, stream_id,
NGHTTP3_HTTP_PUSH_REFUSED); app_error_code);
if (rv != 0) { if (rv != 0) {
std::cerr << "ngtcp2_conn_shutdown_stream_read: " << ngtcp2_strerror(rv) std::cerr << "ngtcp2_conn_shutdown_stream_read: " << ngtcp2_strerror(rv)
<< std::endl; << std::endl;
@ -207,8 +209,8 @@ int Http3Session::send_stop_sending(int64_t stream_id) {
return 0; return 0;
} }
int Http3Session::close_stream(int64_t stream_id, uint16_t error_code) { int Http3Session::close_stream(int64_t stream_id, uint64_t app_error_code) {
auto rv = nghttp3_conn_close_stream(conn_, stream_id, error_code); auto rv = nghttp3_conn_close_stream(conn_, stream_id, app_error_code);
if (rv != 0) { if (rv != 0) {
return -1; return -1;
} }

View File

@ -45,15 +45,15 @@ public:
virtual size_t max_concurrent_streams(); virtual size_t max_concurrent_streams();
int init_conn(); int init_conn();
int stream_close(int64_t stream_id, uint16_t error_code); int stream_close(int64_t stream_id, uint64_t app_error_code);
void recv_data(int64_t stream_id, const uint8_t *data, size_t datalen); void recv_data(int64_t stream_id, const uint8_t *data, size_t datalen);
void consume(int64_t stream_id, size_t nconsumed); void consume(int64_t stream_id, size_t nconsumed);
void begin_headers(int64_t stream_id); void begin_headers(int64_t stream_id);
void recv_header(int64_t stream_id, const nghttp3_vec *name, void recv_header(int64_t stream_id, const nghttp3_vec *name,
const nghttp3_vec *value); const nghttp3_vec *value);
int send_stop_sending(int64_t stream_id); int send_stop_sending(int64_t stream_id, uint64_t app_error_code);
int close_stream(int64_t stream_id, uint16_t error_code); int close_stream(int64_t stream_id, uint64_t app_error_code);
int reset_stream(int64_t stream_id); int reset_stream(int64_t stream_id);
int extend_max_local_streams(); int extend_max_local_streams();
int64_t submit_request_internal(); int64_t submit_request_internal();

View File

@ -305,7 +305,7 @@ int Client::quic_recv_stream_data(int64_t stream_id, int fin,
} }
namespace { namespace {
int stream_close(ngtcp2_conn *conn, int64_t stream_id, uint16_t app_error_code, int stream_close(ngtcp2_conn *conn, int64_t stream_id, uint64_t app_error_code,
void *user_data, void *stream_user_data) { void *user_data, void *stream_user_data) {
auto c = static_cast<Client *>(user_data); auto c = static_cast<Client *>(user_data);
if (c->quic_stream_close(stream_id, app_error_code) != 0) { if (c->quic_stream_close(stream_id, app_error_code) != 0) {
@ -315,7 +315,7 @@ int stream_close(ngtcp2_conn *conn, int64_t stream_id, uint16_t app_error_code,
} }
} // namespace } // namespace
int Client::quic_stream_close(int64_t stream_id, uint16_t app_error_code) { int Client::quic_stream_close(int64_t stream_id, uint64_t app_error_code) {
auto s = static_cast<Http3Session *>(session.get()); auto s = static_cast<Http3Session *>(session.get());
if (s->close_stream(stream_id, app_error_code) != 0) { if (s->close_stream(stream_id, app_error_code) != 0) {
return -1; return -1;
@ -325,7 +325,7 @@ int Client::quic_stream_close(int64_t stream_id, uint16_t app_error_code) {
namespace { namespace {
int stream_reset(ngtcp2_conn *conn, int64_t stream_id, uint64_t final_size, int stream_reset(ngtcp2_conn *conn, int64_t stream_id, uint64_t final_size,
uint16_t app_error_code, void *user_data, uint64_t app_error_code, void *user_data,
void *stream_user_data) { void *stream_user_data) {
auto c = static_cast<Client *>(user_data); auto c = static_cast<Client *>(user_data);
if (c->quic_stream_reset(stream_id, app_error_code) != 0) { if (c->quic_stream_reset(stream_id, app_error_code) != 0) {
@ -335,7 +335,7 @@ int stream_reset(ngtcp2_conn *conn, int64_t stream_id, uint64_t final_size,
} }
} // namespace } // namespace
int Client::quic_stream_reset(int64_t stream_id, uint16_t app_error_code) { int Client::quic_stream_reset(int64_t stream_id, uint64_t app_error_code) {
auto s = static_cast<Http3Session *>(session.get()); auto s = static_cast<Http3Session *>(session.get());
if (s->reset_stream(stream_id) != 0) { if (s->reset_stream(stream_id) != 0) {
return -1; return -1;

View File

@ -88,11 +88,11 @@ enum class ErrorType {
}; };
struct Error { struct Error {
Error(ErrorType type, uint16_t code) : type(type), code(code) {} Error(ErrorType type, uint64_t code) : type(type), code(code) {}
Error() : type(ErrorType::Transport), code(0) {} Error() : type(ErrorType::Transport), code(0) {}
ErrorType type; ErrorType type;
uint16_t code; uint64_t code;
}; };
Error err_transport(int liberr); Error err_transport(int liberr);