Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
08b1c9f9
Commit
08b1c9f9
authored
Jun 30, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chrome does not handle the HTTP 408 status correctly, so just close the connection instead.
parent
220538bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
http-test.c++
c++/src/kj/compat/http-test.c++
+2
-3
http.c++
c++/src/kj/compat/http.c++
+11
-9
No files found.
c++/src/kj/compat/http-test.c++
View file @
08b1c9f9
...
@@ -1165,9 +1165,8 @@ KJ_TEST("HttpServer request timeout") {
...
@@ -1165,9 +1165,8 @@ KJ_TEST("HttpServer request timeout") {
// Shouldn't hang! Should time out.
// Shouldn't hang! Should time out.
server
.
listenHttp
(
kj
::
mv
(
pipe
.
ends
[
0
])).
wait
(
io
.
waitScope
);
server
.
listenHttp
(
kj
::
mv
(
pipe
.
ends
[
0
])).
wait
(
io
.
waitScope
);
// Sends back 408 Request Timeout.
// Closes the connection without sending anything.
KJ_EXPECT
(
pipe
.
ends
[
1
]
->
readAllText
().
wait
(
io
.
waitScope
)
KJ_EXPECT
(
pipe
.
ends
[
1
]
->
readAllText
().
wait
(
io
.
waitScope
)
==
""
);
.
startsWith
(
"HTTP/1.1 408 Request Timeout"
));
}
}
KJ_TEST
(
"HttpServer pipeline timeout"
)
{
KJ_TEST
(
"HttpServer pipeline timeout"
)
{
...
...
c++/src/kj/compat/http.c++
View file @
08b1c9f9
...
@@ -1773,15 +1773,17 @@ public:
...
@@ -1773,15 +1773,17 @@ public:
return
httpOutput
.
flush
();
return
httpOutput
.
flush
();
}
}
if
(
timedOut
)
{
if
(
timedOut
)
{
if
(
firstRequest
)
{
// Client took too long to send anything, so we're going to close the connection. In
return
sendError
(
408
,
"Request Timeout"
,
kj
::
str
(
// theory, we should send back an HTTP 408 error -- it is designed exactly for this
"ERROR: Your client took too long to send HTTP headers."
));
// purpose. Alas, in practice, Google Chrome does not have any special handling for 408
}
else
{
// errors -- it will assume the error is a response to the next request it tries to send,
// After the first request, we just close the connection if the client takes too long,
// and will happily serve the error to the user. OTOH, if we simply close the connection,
// on the assumption that the client is intentionally trying to keep the connection
// Chrome does the "right thing", apparently. (Though I'm not sure what happens if a
// around for reuse (not necessarily an error).
// request is in-flight when we close... if it's a GET, the browser should retry. But if
return
httpOutput
.
flush
();
// it's a POST, retrying may be dangerous. This is why 408 exists -- it unambiguously
}
// tells the client that it should retry.)
return
httpOutput
.
flush
();
}
}
KJ_IF_MAYBE
(
req
,
request
)
{
KJ_IF_MAYBE
(
req
,
request
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment