Skip to content

Commit 71667f3

Browse files
author
Erik Corry
authored
Throw more reliably for multiple requests on client. (#74)
* Throw more reliably for multiple requests on client. Sets the current_writer_ at an earlier point so that we detect multiple tasks trying to write requests on the same client more reliably. * Remove flaky httpbin.org test on non-Linux
1 parent 48409e1 commit 71667f3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ jobs:
9494
docker ps
9595
cmake -DENABLE_HTTPBIN_TESTS=ON -DUSE_HTTPBIN_DOCKER=ON build
9696
97+
# httpbin.org is overloaded at the moment, so if we are not running our
98+
# own in Docker, don't run it at all.
99+
- name: Enable httpbin tests - non-Linux
100+
if: runner.os != 'Linux'
101+
run: |
102+
cmake -DENABLE_HTTPBIN_TESTS=OFF build
103+
97104
- name: Install packages
98105
run: |
99106
make install-pkgs

src/connection.toit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ class Connection:
109109
if not headers.matches "Connection" "upgrade":
110110
headers.set "Content-Length" "0"
111111

112+
// Set this before doing blocking operations on the socket, so that we
113+
// don't let another task start another request on the same connection.
114+
current_writer_ = body_writer
115+
112116
socket_.set_no_delay false
113117

114118
writer_.write status
@@ -120,7 +124,6 @@ class Connection:
120124
writer_.write "\r\n"
121125

122126
socket_.set_no_delay true
123-
current_writer_ = body_writer
124127
return body_writer
125128

126129
// Gets the next request from the client. If the client closes the

tests/redirect_test_httpbin.toit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ main args:
125125
else:
126126
HOST = host_port
127127

128+
if HOST == "httpbin.org":
129+
print "May timeout if httpbin is overloaded."
130+
128131
network := net.open
129132

130133
test_get network

0 commit comments

Comments
 (0)