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
19 changes: 9 additions & 10 deletions tests/mock_server/h2tls_mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def __init__(self):
self.stream_data = {}
self.flow_control_futures = {}
self.file_path = None
self.num_sentence_received = {}
self.raw_headers = None
self.download_test_length = 2500000000
self.out_bytes_per_second = 900
Expand Down Expand Up @@ -118,7 +117,7 @@ def handle_request_echo(self, stream_id: int, request_data: RequestData):
- x-repeat-data: <bytes> - Triggers send_repeat_data() with specified length
- x-slow-response: true - Triggers send_slow_repeat_data() instead (requires x-repeat-data)
- x-throughput-bps: <number> - Override throughput for slow response (default 900)

Without special headers, echoes request headers and body as JSON.
"""
headers_dict = dict(self.raw_headers)
Expand All @@ -128,15 +127,15 @@ def handle_request_echo(self, stream_id: int, request_data: RequestData):
response_headers = [(':status', expect_status)]
self.conn.send_headers(stream_id, response_headers, end_stream=True)
return

# Check for x-repeat-data header
repeat_data_header = headers_dict.get('x-repeat-data')
if repeat_data_header:
try:
length = int(repeat_data_header)
response_headers = [(':status', '200')]
self.conn.send_headers(stream_id, response_headers, end_stream=False)

# Check for slow response
if headers_dict.get('x-slow-response') == 'true':
# Check for custom throughput
Expand All @@ -149,7 +148,7 @@ def handle_request_echo(self, stream_id: int, request_data: RequestData):
return
except ValueError:
pass # Fall through to echo behavior

# Check for upload test (don't echo body, just return byte count)
if headers_dict.get('x-upload-test') == 'true':
body_bytes = request_data.data.getvalue()
Expand All @@ -158,7 +157,7 @@ def handle_request_echo(self, stream_id: int, request_data: RequestData):
self.conn.send_headers(stream_id, response_headers, end_stream=False)
asyncio.ensure_future(self.send_data(data, stream_id))
return

# Default echo behavior
response_headers = [(':status', '200')]
# Filter out headers that shouldn't be echoed back
Expand All @@ -167,18 +166,18 @@ def handle_request_echo(self, stream_id: int, request_data: RequestData):
# Response headers back and exclude pseudo headers and problematic headers
if i[0][0] != ':' and i[0].lower() not in skip_headers:
response_headers.append(i)

body_bytes = request_data.data.getvalue()

body = body_bytes.decode('utf-8')

data = json.dumps(
{"body": body, "bytes": len(body_bytes)}, indent=4,
).encode("utf8")

# Add correct content-length for our response
response_headers.append(('content-length', str(len(data))))

self.conn.send_headers(stream_id, response_headers, end_stream=False)
asyncio.ensure_future(self.send_data(data, stream_id))

Expand Down
2 changes: 1 addition & 1 deletion tests/test_connection_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int s_do_http_monitoring_test(
}

static struct aws_http_connection_monitoring_options s_test_options = {
.allowable_throughput_failure_interval_seconds = 1,
.allowable_throughput_failure_interval_seconds = 2,
.minimum_throughput_bytes_per_second = 1000,
};

Expand Down
2 changes: 1 addition & 1 deletion tests/test_stream_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ TEST_CASE(localhost_integ_h2_sm_connection_monitor_kill_slow_connection) {
(void)ctx;
struct aws_byte_cursor uri_cursor = aws_byte_cursor_from_c_str("https://localhost:3443/echo");
struct aws_http_connection_monitoring_options monitor_opt = {
.allowable_throughput_failure_interval_seconds = 1,
.allowable_throughput_failure_interval_seconds = 2,
.minimum_throughput_bytes_per_second = 1000,
};
struct sm_tester_options options = {
Expand Down
Loading