fix(server): ignore expect-continue with no body in debug mode
Closes #1843
This commit is contained in:
@@ -151,7 +151,9 @@ where I: AsyncRead + AsyncWrite + Unpin,
|
|||||||
self.state.version = msg.head.version;
|
self.state.version = msg.head.version;
|
||||||
|
|
||||||
if msg.decode == DecodedLength::ZERO {
|
if msg.decode == DecodedLength::ZERO {
|
||||||
debug_assert!(!msg.expect_continue, "expect-continue needs a body");
|
if log_enabled!(log::Level::Debug) && msg.expect_continue {
|
||||||
|
debug!("ignoring expect-continue since body is empty");
|
||||||
|
}
|
||||||
self.state.reading = Reading::KeepAlive;
|
self.state.reading = Reading::KeepAlive;
|
||||||
if !T::should_read_first() {
|
if !T::should_read_first() {
|
||||||
self.try_keep_alive(cx);
|
self.try_keep_alive(cx);
|
||||||
|
|||||||
@@ -724,6 +724,28 @@ fn expect_continue_sends_100() {
|
|||||||
assert_eq!(body, msg);
|
assert_eq!(body, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn expect_continue_but_no_body_is_ignored() {
|
||||||
|
let server = serve();
|
||||||
|
let mut req = connect(server.addr());
|
||||||
|
server.reply();
|
||||||
|
|
||||||
|
// no content-length or transfer-encoding means no body!
|
||||||
|
req.write_all(b"\
|
||||||
|
POST /foo HTTP/1.1\r\n\
|
||||||
|
Host: example.domain\r\n\
|
||||||
|
Expect: 100-continue\r\n\
|
||||||
|
Connection: Close\r\n\
|
||||||
|
\r\n\
|
||||||
|
").expect("write");
|
||||||
|
|
||||||
|
let expected = "HTTP/1.1 200 OK\r\n";
|
||||||
|
let mut resp = String::new();
|
||||||
|
req.read_to_string(&mut resp).expect("read");
|
||||||
|
|
||||||
|
assert_eq!(&resp[..expected.len()], expected);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pipeline_disabled() {
|
fn pipeline_disabled() {
|
||||||
let server = serve();
|
let server = serve();
|
||||||
|
|||||||
Reference in New Issue
Block a user