Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/aws/http/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum aws_http_errors {
AWS_ERROR_HTTP_RESPONSE_FIRST_BYTE_TIMEOUT,
AWS_ERROR_HTTP_CONNECTION_MANAGER_ACQUISITION_TIMEOUT,
AWS_ERROR_HTTP_CONNECTION_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED,
AWS_ERROR_HTTP_STREAM_CANCELLED,

AWS_ERROR_HTTP_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_HTTP_PACKAGE_ID)
};
Expand Down
6 changes: 6 additions & 0 deletions include/aws/http/request_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,12 @@ uint32_t aws_http_stream_get_id(const struct aws_http_stream *stream);
*/
AWS_HTTP_API
void aws_http_stream_cancel(struct aws_http_stream *stream, int error_code);
/**
* Cancel the stream with default error code.
* Equivalent to invoke aws_http_stream_cancel with AWS_ERROR_HTTP_STREAM_CANCELLED.
*/
AWS_HTTP_API
void aws_http_stream_cancel_default_error(struct aws_http_stream *stream);

/**
* Reset the HTTP/2 stream (HTTP/2 only).
Expand Down
3 changes: 3 additions & 0 deletions source/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ static struct aws_error_info s_errors[] = {
AWS_DEFINE_ERROR_INFO_HTTP(
AWS_ERROR_HTTP_CONNECTION_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED,
"Max pending acquisitions reached"),
AWS_DEFINE_ERROR_INFO_HTTP(
AWS_ERROR_HTTP_STREAM_CANCELLED,
"In-flight HTTP-stream has been cancelled by user."),
};
/* clang-format on */

Expand Down
4 changes: 4 additions & 0 deletions source/request_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,10 @@ void aws_http_stream_cancel(struct aws_http_stream *stream, int error_code) {
stream->vtable->cancel(stream, error_code);
}

void aws_http_stream_cancel_default_error(struct aws_http_stream *stream) {
stream->vtable->cancel(stream, AWS_ERROR_HTTP_STREAM_CANCELLED);
}

int aws_http2_stream_reset(struct aws_http_stream *http2_stream, uint32_t http2_error) {
AWS_PRECONDITION(http2_stream);
AWS_PRECONDITION(http2_stream->vtable);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_h2_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4542,12 +4542,12 @@ TEST_CASE(h2_client_stream_cancel_stream) {
testing_channel_drain_queued_tasks(&s_tester.testing_channel);

/* Cancel the request */
aws_http_stream_cancel(stream_tester.stream, AWS_ERROR_COND_VARIABLE_ERROR_UNKNOWN);
aws_http_stream_cancel_default_error(stream_tester.stream);
testing_channel_drain_queued_tasks(&s_tester.testing_channel);

ASSERT_TRUE(aws_http_connection_is_open(s_tester.connection));
ASSERT_TRUE(stream_tester.complete);
ASSERT_INT_EQUALS(AWS_ERROR_COND_VARIABLE_ERROR_UNKNOWN, stream_tester.on_complete_error_code);
ASSERT_INT_EQUALS(AWS_ERROR_HTTP_STREAM_CANCELLED, stream_tester.on_complete_error_code);
/* validate that stream sent RST_STREAM */
ASSERT_SUCCESS(h2_fake_peer_decode_messages_from_testing_channel(&s_tester.peer));
struct h2_decoded_frame *rst_stream_frame =
Expand Down
Loading