Use uint32_t for HTTP/2 error_code

h2-14 now allows extensions to define new error codes.  To allow
application callback to access such error codes, we uses uint32_t as
error_code type for structs and function parameters.  Previously we
treated unknown error code as INTERNAL_ERROR, but this change removes
this and unknown error code is passed to application callback as is.
This commit is contained in:
Tatsuhiro Tsujikawa 2014-08-23 17:34:56 +09:00
parent ab5b81bee1
commit 31528b6267
22 changed files with 85 additions and 105 deletions

View File

@ -845,7 +845,7 @@ typedef struct {
/**
* The error code. See :type:`nghttp2_error_code`.
*/
nghttp2_error_code error_code;
uint32_t error_code;
} nghttp2_rst_stream;
/**
@ -946,7 +946,7 @@ typedef struct {
/**
* The error code. See :type:`nghttp2_error_code`.
*/
nghttp2_error_code error_code;
uint32_t error_code;
/**
* The additional debug data
*/
@ -1178,12 +1178,13 @@ typedef int (*nghttp2_on_frame_recv_callback)
* @functypedef
*
* Callback function invoked by `nghttp2_session_recv()` when an
* invalid non-DATA frame is received. The |error_code| is one of the
* :enum:`nghttp2_error_code` and indicates the error. When this
* callback function is invoked, the library automatically submits
* either RST_STREAM or GOAWAY frame. The |user_data| pointer is the
* third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.
* invalid non-DATA frame is received. The |error_code| indicates the
* error. It is usually one of the :enum:`nghttp2_error_code` but
* that is not guaranteed. When this callback function is invoked,
* the library automatically submits either RST_STREAM or GOAWAY
* frame. The |user_data| pointer is the third argument passed in to
* the call to `nghttp2_session_client_new()` or
* `nghttp2_session_server_new()`.
*
* If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen``
* member of their data structure are always ``NULL`` and 0
@ -1199,7 +1200,7 @@ typedef int (*nghttp2_on_frame_recv_callback)
*/
typedef int (*nghttp2_on_invalid_frame_recv_callback)
(nghttp2_session *session, const nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data);
uint32_t error_code, void *user_data);
/**
* @functypedef
@ -1299,10 +1300,11 @@ typedef int (*nghttp2_on_frame_not_send_callback)
*
* Callback function invoked when the stream |stream_id| is closed.
* The reason of closure is indicated by the |error_code|. The
* stream_user_data, which was specified in `nghttp2_submit_request()`
* or `nghttp2_submit_headers()`, is still available in this function.
* The |user_data| pointer is the third argument passed in to the call
* to `nghttp2_session_client_new()` or
* |error_code| is usually one of :enum:`nghttp2_error_code`, but that
* is not guaranteed. The stream_user_data, which was specified in
* `nghttp2_submit_request()` or `nghttp2_submit_headers()`, is still
* available in this function. The |user_data| pointer is the third
* argument passed in to the call to `nghttp2_session_client_new()` or
* `nghttp2_session_server_new()`.
*
* This function is also called for a stream in reserved state.
@ -1316,7 +1318,7 @@ typedef int (*nghttp2_on_frame_not_send_callback)
* `nghttp2_session_callbacks_set_on_stream_close_callback()`.
*/
typedef int (*nghttp2_on_stream_close_callback)
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
(nghttp2_session *session, int32_t stream_id, uint32_t error_code,
void *user_data);
/**
@ -2173,7 +2175,8 @@ int nghttp2_session_get_stream_remote_close(nghttp2_session* session,
* The last stream ID is the ID of a stream for which
* :type:`nghttp2_on_frame_recv_callback` was called most recently.
*
* The |error_code| is the error code of this GOAWAY frame.
* The |error_code| is the error code of this GOAWAY frame. The
* pre-defined error code is one of :enum:`nghttp2_error_code`.
*
* After the transmission, both `nghttp2_session_want_read()` and
* `nghttp2_session_want_write()` return 0.
@ -2189,7 +2192,7 @@ int nghttp2_session_get_stream_remote_close(nghttp2_session* session,
* Out of memory.
*/
int nghttp2_session_terminate_session(nghttp2_session *session,
nghttp2_error_code error_code);
uint32_t error_code);
/**
* @function
@ -2208,7 +2211,7 @@ int nghttp2_session_terminate_session(nghttp2_session *session,
*/
int nghttp2_session_terminate_session2(nghttp2_session *session,
int32_t last_stream_id,
nghttp2_error_code error_code);
uint32_t error_code);
/**
* @function
@ -2603,6 +2606,8 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
* Submits RST_STREAM frame to cancel/reject the stream |stream_id|
* with the error code |error_code|.
*
* The pre-defined error code is one of :enum:`nghttp2_error_code`.
*
* The |flags| is currently ignored and should be
* :enum:`NGHTTP2_FLAG_NONE`.
*
@ -2616,7 +2621,7 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
*/
int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags,
int32_t stream_id,
nghttp2_error_code error_code);
uint32_t error_code);
/**
* @function
@ -2743,6 +2748,8 @@ int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags,
* Submits GOAWAY frame with the last stream ID |last_stream_id| and
* the error code |error_code|.
*
* The pre-defined error code is one of :enum:`nghttp2_error_code`.
*
* The |flags| is currently ignored and should be
* :enum:`NGHTTP2_FLAG_NONE`.
*
@ -2769,7 +2776,7 @@ int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags,
*/
int nghttp2_submit_goaway(nghttp2_session *session, uint8_t flags,
int32_t last_stream_id,
nghttp2_error_code error_code,
uint32_t error_code,
const uint8_t *opaque_data, size_t opaque_data_len);
/**

View File

@ -101,7 +101,7 @@ void nghttp2_frame_priority_free(nghttp2_priority *frame)
void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame,
int32_t stream_id,
nghttp2_error_code error_code)
uint32_t error_code)
{
frame_set_hd(&frame->hd, 4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE,
stream_id);
@ -158,7 +158,7 @@ void nghttp2_frame_ping_free(nghttp2_ping *frame)
{}
void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id,
nghttp2_error_code error_code,
uint32_t error_code,
uint8_t *opaque_data, size_t opaque_data_len)
{
frame_set_hd(&frame->hd, 8+opaque_data_len, NGHTTP2_GOAWAY,
@ -477,33 +477,11 @@ int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs,
return 0;
}
static nghttp2_error_code normalize_error_code(uint32_t error_code)
{
switch(error_code) {
case NGHTTP2_NO_ERROR:
case NGHTTP2_PROTOCOL_ERROR:
case NGHTTP2_INTERNAL_ERROR:
case NGHTTP2_FLOW_CONTROL_ERROR:
case NGHTTP2_SETTINGS_TIMEOUT:
case NGHTTP2_STREAM_CLOSED:
case NGHTTP2_FRAME_SIZE_ERROR:
case NGHTTP2_REFUSED_STREAM:
case NGHTTP2_CANCEL:
case NGHTTP2_COMPRESSION_ERROR:
case NGHTTP2_CONNECT_ERROR:
case NGHTTP2_ENHANCE_YOUR_CALM:
case NGHTTP2_INADEQUATE_SECURITY:
return error_code;
default:
return NGHTTP2_INTERNAL_ERROR;
}
}
void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame,
const uint8_t *payload,
size_t payloadlen)
{
frame->error_code = normalize_error_code(nghttp2_get_uint32(payload));
frame->error_code = nghttp2_get_uint32(payload);
}
int nghttp2_frame_pack_settings(nghttp2_bufs *bufs, nghttp2_settings *frame)
@ -712,7 +690,7 @@ void nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame,
size_t var_gift_payloadlen)
{
frame->last_stream_id = nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK;
frame->error_code = normalize_error_code(nghttp2_get_uint32(payload + 4));
frame->error_code = nghttp2_get_uint32(payload + 4);
frame->opaque_data = var_gift_payload;
frame->opaque_data_len = var_gift_payloadlen;

View File

@ -477,7 +477,7 @@ void nghttp2_frame_priority_free(nghttp2_priority *frame);
void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame,
int32_t stream_id,
nghttp2_error_code error_code);
uint32_t error_code);
void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame);
@ -519,7 +519,7 @@ void nghttp2_frame_ping_free(nghttp2_ping *frame);
* free it. If the |opaque_data_len| is 0, opaque_data could be NULL.
*/
void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id,
nghttp2_error_code error_code,
uint32_t error_code,
uint8_t *opaque_data, size_t opaque_data_len);
void nghttp2_frame_goaway_free(nghttp2_goaway *frame);

View File

@ -134,7 +134,7 @@ static int session_detect_idle_stream(nghttp2_session *session,
static int session_terminate_session
(nghttp2_session *session, int32_t last_stream_id,
nghttp2_error_code error_code, const char *reason)
uint32_t error_code, const char *reason)
{
const uint8_t *debug_data;
size_t debug_datalen;
@ -157,7 +157,7 @@ static int session_terminate_session
}
int nghttp2_session_terminate_session(nghttp2_session *session,
nghttp2_error_code error_code)
uint32_t error_code)
{
return session_terminate_session(session, session->last_proc_stream_id,
error_code, NULL);
@ -165,13 +165,13 @@ int nghttp2_session_terminate_session(nghttp2_session *session,
int nghttp2_session_terminate_session2(nghttp2_session *session,
int32_t last_stream_id,
nghttp2_error_code error_code)
uint32_t error_code)
{
return session_terminate_session(session, last_stream_id, error_code, NULL);
}
int nghttp2_session_terminate_session_with_reason
(nghttp2_session *session, nghttp2_error_code error_code, const char *reason)
(nghttp2_session *session, uint32_t error_code, const char *reason)
{
return session_terminate_session(session, session->last_proc_stream_id,
error_code, reason);
@ -707,7 +707,7 @@ int nghttp2_session_add_frame(nghttp2_session *session,
int nghttp2_session_add_rst_stream(nghttp2_session *session,
int32_t stream_id,
nghttp2_error_code error_code)
uint32_t error_code)
{
int rv;
nghttp2_frame *frame;
@ -832,7 +832,7 @@ nghttp2_stream* nghttp2_session_open_stream(nghttp2_session *session,
}
int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id,
nghttp2_error_code error_code)
uint32_t error_code)
{
int rv;
nghttp2_stream *stream;
@ -2525,7 +2525,7 @@ static int session_handle_frame_size_error(nghttp2_session *session,
static int session_handle_invalid_stream
(nghttp2_session *session,
nghttp2_frame *frame,
nghttp2_error_code error_code)
uint32_t error_code)
{
int rv;
rv = nghttp2_session_add_rst_stream(session, frame->hd.stream_id, error_code);
@ -2544,7 +2544,7 @@ static int session_handle_invalid_stream
static int session_inflate_handle_invalid_stream
(nghttp2_session *session,
nghttp2_frame *frame,
nghttp2_error_code error_code)
uint32_t error_code)
{
int rv;
rv = session_handle_invalid_stream(session, frame, error_code);
@ -2560,7 +2560,7 @@ static int session_inflate_handle_invalid_stream
static int session_handle_invalid_connection
(nghttp2_session *session,
nghttp2_frame *frame,
nghttp2_error_code error_code,
uint32_t error_code,
const char *reason)
{
if(session->callbacks.on_invalid_frame_recv_callback) {
@ -2576,7 +2576,7 @@ static int session_handle_invalid_connection
static int session_inflate_handle_invalid_connection
(nghttp2_session *session,
nghttp2_frame *frame,
nghttp2_error_code error_code,
uint32_t error_code,
const char *reason)
{
int rv;
@ -3345,7 +3345,7 @@ int nghttp2_session_on_settings_received(nghttp2_session *session,
session->inflight_iv = NULL;
session->inflight_niv = -1;
if(rv != 0) {
nghttp2_error_code error_code = NGHTTP2_INTERNAL_ERROR;
uint32_t error_code = NGHTTP2_INTERNAL_ERROR;
if(nghttp2_is_fatal(rv)) {
return rv;
}
@ -5416,7 +5416,7 @@ int nghttp2_session_add_ping(nghttp2_session *session, uint8_t flags,
int nghttp2_session_add_goaway(nghttp2_session *session,
int32_t last_stream_id,
nghttp2_error_code error_code,
uint32_t error_code,
const uint8_t *opaque_data,
size_t opaque_data_len)
{

View File

@ -290,7 +290,7 @@ int nghttp2_session_add_frame(nghttp2_session *session,
*/
int nghttp2_session_add_rst_stream(nghttp2_session *session,
int32_t stream_id,
nghttp2_error_code error_code);
uint32_t error_code);
/*
* Adds PING frame. This is a convenient functin built on top of
@ -324,7 +324,7 @@ int nghttp2_session_add_ping(nghttp2_session *session, uint8_t flags,
*/
int nghttp2_session_add_goaway(nghttp2_session *session,
int32_t last_stream_id,
nghttp2_error_code error_code,
uint32_t error_code,
const uint8_t *opaque_data,
size_t opaque_data_len);
@ -396,7 +396,7 @@ nghttp2_stream* nghttp2_session_open_stream(nghttp2_session *session,
* The callback function failed.
*/
int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id,
nghttp2_error_code error_code);
uint32_t error_code);
/*
* Deletes |stream| from memory. After this function returns, stream
@ -739,6 +739,6 @@ int nghttp2_session_reprioritize_stream
* The |reason| is too long.
*/
int nghttp2_session_terminate_session_with_reason
(nghttp2_session *session, nghttp2_error_code error_code, const char *reason);
(nghttp2_session *session, uint32_t error_code, const char *reason);
#endif /* NGHTTP2_SESSION_H */

View File

@ -234,7 +234,7 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags,
int32_t stream_id,
nghttp2_error_code error_code)
uint32_t error_code)
{
if(stream_id == 0) {
return NGHTTP2_ERR_INVALID_ARGUMENT;
@ -245,7 +245,7 @@ int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags,
int nghttp2_submit_goaway(nghttp2_session *session, uint8_t flags,
int32_t last_stream_id,
nghttp2_error_code error_code,
uint32_t error_code,
const uint8_t *opaque_data, size_t opaque_data_len)
{
return nghttp2_session_add_goaway(session, last_stream_id,

View File

@ -903,8 +903,7 @@ int Http2Handler::submit_push_promise(Stream *stream,
return 0;
}
int Http2Handler::submit_rst_stream(Stream *stream,
nghttp2_error_code error_code)
int Http2Handler::submit_rst_stream(Stream *stream, uint32_t error_code)
{
remove_stream_read_timeout(stream);
remove_stream_write_timeout(stream);
@ -967,7 +966,7 @@ void Http2Handler::remove_settings_timer()
}
}
void Http2Handler::terminate_session(nghttp2_error_code error_code)
void Http2Handler::terminate_session(uint32_t error_code)
{
nghttp2_session_terminate_session(session_, error_code);
}
@ -1430,7 +1429,7 @@ int on_data_chunk_recv_callback
namespace {
int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
(nghttp2_session *session, int32_t stream_id, uint32_t error_code,
void *user_data)
{
auto hd = static_cast<Http2Handler*>(user_data);

View File

@ -130,7 +130,7 @@ public:
int submit_push_promise(Stream *stream, const std::string& push_path);
int submit_rst_stream(Stream *stream, nghttp2_error_code error_code);
int submit_rst_stream(Stream *stream, uint32_t error_code);
void add_stream(int32_t stream_id, std::unique_ptr<Stream> stream);
void remove_stream(int32_t stream_id);
@ -141,7 +141,7 @@ public:
size_t get_left_connhd_len() const;
void set_left_connhd_len(size_t left);
void remove_settings_timer();
void terminate_session(nghttp2_error_code error_code);
void terminate_session(uint32_t error_code);
int tls_handshake();
private:
int handle_ssl_temporal_error(int err);

View File

@ -52,7 +52,7 @@
namespace nghttp2 {
namespace {
const char* strstatus(nghttp2_error_code error_code)
const char* strstatus(uint32_t error_code)
{
switch(error_code) {
case NGHTTP2_NO_ERROR:
@ -464,7 +464,7 @@ int verbose_on_frame_recv_callback
int verbose_on_invalid_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data)
uint32_t error_code, void *user_data)
{
print_timer();
fprintf(outfile, " [INVALID; status=%s] recv ", strstatus(error_code));

View File

@ -51,7 +51,7 @@ int verbose_on_frame_recv_callback
int verbose_on_invalid_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data);
uint32_t error_code, void *user_data);
int verbose_on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *head,

View File

@ -89,7 +89,7 @@ int on_data_chunk_recv_callback
namespace {
int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
(nghttp2_session *session, int32_t stream_id, uint32_t error_code,
void *user_data)
{
auto client = static_cast<Client*>(user_data);

View File

@ -1474,7 +1474,7 @@ int on_frame_recv_callback2
namespace {
int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
(nghttp2_session *session, int32_t stream_id, uint32_t error_code,
void *user_data)
{
auto client = get_session(user_data);

View File

@ -54,7 +54,7 @@ Downstream::Downstream(Upstream *upstream, int32_t stream_id, int32_t priority)
stream_id_(stream_id),
priority_(priority),
downstream_stream_id_(-1),
response_rst_stream_error_code_(-1),
response_rst_stream_error_code_(NGHTTP2_NO_ERROR),
request_state_(INITIAL),
request_major_(1),
request_minor_(1),
@ -848,12 +848,12 @@ int32_t Downstream::get_downstream_stream_id() const
return downstream_stream_id_;
}
int Downstream::get_response_rst_stream_error_code() const
uint32_t Downstream::get_response_rst_stream_error_code() const
{
return response_rst_stream_error_code_;
}
void Downstream::set_response_rst_stream_error_code(int error_code)
void Downstream::set_response_rst_stream_error_code(uint32_t error_code)
{
response_rst_stream_error_code_ = error_code;
}

View File

@ -215,8 +215,8 @@ public:
evbuffer* get_response_body_buf();
void add_response_bodylen(size_t amount);
int64_t get_response_bodylen() const;
int get_response_rst_stream_error_code() const;
void set_response_rst_stream_error_code(int error_code);
uint32_t get_response_rst_stream_error_code() const;
void set_response_rst_stream_error_code(uint32_t error_code);
// Inspects HTTP/1 response. This checks tranfer-encoding etc.
void inspect_http1_response();
// Clears some of member variables for response.
@ -311,7 +311,7 @@ private:
int32_t downstream_stream_id_;
// RST_STREAM error_code from downstream HTTP2 connection
int response_rst_stream_error_code_;
uint32_t response_rst_stream_error_code_;
int request_state_;
int request_major_;

View File

@ -153,7 +153,7 @@ void Http2DownstreamConnection::detach_downstream(Downstream *downstream)
}
int Http2DownstreamConnection::submit_rst_stream(Downstream *downstream,
nghttp2_error_code error_code)
uint32_t error_code)
{
int rv = -1;
if(http2session_->get_state() == Http2Session::CONNECTED &&

View File

@ -71,8 +71,7 @@ public:
StreamData* detach_stream_data();
int submit_rst_stream
(Downstream *downstream,
nghttp2_error_code error_code = NGHTTP2_INTERNAL_ERROR);
(Downstream *downstream, uint32_t error_code = NGHTTP2_INTERNAL_ERROR);
private:
Http2Session *http2session_;
evbuffer *request_body_buf_;

View File

@ -669,8 +669,7 @@ int Http2Session::submit_request(Http2DownstreamConnection *dconn,
return 0;
}
int Http2Session::submit_rst_stream(int32_t stream_id,
nghttp2_error_code error_code)
int Http2Session::submit_rst_stream(int32_t stream_id, uint32_t error_code)
{
assert(state_ == CONNECTED);
if(LOG_ENABLED(INFO)) {
@ -755,7 +754,7 @@ void call_downstream_readcb(Http2Session *http2session, Downstream *downstream)
namespace {
int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
(nghttp2_session *session, int32_t stream_id, uint32_t error_code,
void *user_data)
{
auto http2session = static_cast<Http2Session*>(user_data);
@ -1632,7 +1631,7 @@ void Http2Session::set_state(int state)
state_ = state;
}
int Http2Session::terminate_session(nghttp2_error_code error_code)
int Http2Session::terminate_session(uint32_t error_code)
{
int rv;
rv = nghttp2_session_terminate_session(session_, error_code);

View File

@ -68,11 +68,11 @@ public:
int32_t pri, const nghttp2_nv *nva, size_t nvlen,
const nghttp2_data_provider *data_prd);
int submit_rst_stream(int32_t stream_id, nghttp2_error_code error_code);
int submit_rst_stream(int32_t stream_id, uint32_t error_code);
int submit_priority(Http2DownstreamConnection *dconn, int32_t pri);
int terminate_session(nghttp2_error_code error_code);
int terminate_session(uint32_t error_code);
nghttp2_session* get_session() const;

View File

@ -52,7 +52,7 @@ const size_t INBUF_MAX_THRES = 16*1024;
namespace {
int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
(nghttp2_session *session, int32_t stream_id, uint32_t error_code,
void *user_data)
{
auto upstream = static_cast<Http2Upstream*>(user_data);
@ -622,15 +622,14 @@ int on_unknown_frame_recv_callback(nghttp2_session *session,
} // namespace
namespace {
nghttp2_error_code infer_upstream_rst_stream_error_code
(int downstream_error_code)
uint32_t infer_upstream_rst_stream_error_code(uint32_t downstream_error_code)
{
// NGHTTP2_REFUSED_STREAM is important because it tells upstream
// client to retry.
switch(downstream_error_code) {
case NGHTTP2_NO_ERROR:
case NGHTTP2_REFUSED_STREAM:
return static_cast<nghttp2_error_code>(downstream_error_code);
return downstream_error_code;
default:
return NGHTTP2_INTERNAL_ERROR;
}
@ -1045,8 +1044,7 @@ void downstream_eventcb(bufferevent *bev, short events, void *ptr)
}
} // namespace
int Http2Upstream::rst_stream(Downstream *downstream,
nghttp2_error_code error_code)
int Http2Upstream::rst_stream(Downstream *downstream, uint32_t error_code)
{
if(LOG_ENABLED(INFO)) {
ULOG(INFO, this) << "RST_STREAM stream_id="
@ -1065,7 +1063,7 @@ int Http2Upstream::rst_stream(Downstream *downstream,
return 0;
}
int Http2Upstream::terminate_session(nghttp2_error_code error_code)
int Http2Upstream::terminate_session(uint32_t error_code)
{
int rv;
rv = nghttp2_session_terminate_session(session_, error_code);

View File

@ -60,8 +60,8 @@ public:
nghttp2_session* get_http2_session();
int rst_stream(Downstream *downstream, nghttp2_error_code error_code);
int terminate_session(nghttp2_error_code error_code);
int rst_stream(Downstream *downstream, uint32_t error_code);
int terminate_session(uint32_t error_code);
int error_reply(Downstream *downstream, unsigned int status_code);
virtual void pause_read(IOCtrlReason reason);

View File

@ -420,7 +420,7 @@ void on_unknown_ctrl_recv_callback(spdylay_session *session,
namespace {
// Infer upstream RST_STREAM status code from downstream HTTP/2
// error code.
uint32_t infer_upstream_rst_stream_status_code(int downstream_error_code)
uint32_t infer_upstream_rst_stream_status_code(uint32_t downstream_error_code)
{
// Only propagate *_REFUSED_STREAM so that upstream client can
// resend request.

View File

@ -260,7 +260,7 @@ void test_nghttp2_frame_pack_rst_stream(void)
nghttp2_frame_rst_stream_free(&oframe);
nghttp2_bufs_reset(&bufs);
/* Unknown error code is treated as NGHTTP2_INTERNAL_ERROR */
/* Unknown error code is passed to callback as is */
frame.error_code = 1000000009;
rv = nghttp2_frame_pack_rst_stream(&bufs, &frame);
@ -270,7 +270,7 @@ void test_nghttp2_frame_pack_rst_stream(void)
check_frame_header(4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE, 1000000007,
&oframe.hd);
CU_ASSERT(NGHTTP2_INTERNAL_ERROR == oframe.error_code);
CU_ASSERT(1000000009 == oframe.error_code);
nghttp2_frame_rst_stream_free(&oframe);
@ -424,7 +424,7 @@ void test_nghttp2_frame_pack_goaway()
nghttp2_frame_goaway_free(&oframe);
nghttp2_bufs_reset(&bufs);
/* Unknown error code is treated as NGHTTP2_INTERNAL_ERROR */
/* Unknown error code is passed to callback as is */
frame.error_code = 1000000009;
rv = nghttp2_frame_pack_goaway(&bufs, &frame);
@ -432,7 +432,7 @@ void test_nghttp2_frame_pack_goaway()
CU_ASSERT(0 == rv);
CU_ASSERT(0 == unpack_framebuf((nghttp2_frame*)&oframe, &bufs));
check_frame_header(24, NGHTTP2_GOAWAY, NGHTTP2_FLAG_NONE, 0, &oframe.hd);
CU_ASSERT(NGHTTP2_INTERNAL_ERROR == oframe.error_code);
CU_ASSERT(1000000009 == oframe.error_code);
nghttp2_frame_goaway_free(&oframe);