🏡 index : ~doyle/scrs.git

author Jordan Doyle <jordan@doyle.la> 2020-07-20 0:29:49.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2020-07-20 0:29:49.0 +01:00:00
commit
2607d45e7a61c2427348f10d0115ae713e4e9af3 [patch]
tree
b855d084c8bafacc90ba66c1720d09e2e4097699
parent
89e860b65e7db7961ce3c077e29243aec85c79da
download
2607d45e7a61c2427348f10d0115ae713e4e9af3.tar.gz

Correctly return a 100 Continue to streaming clients that expect it



Diff

 scrs-serve/src/main.rs | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scrs-serve/src/main.rs b/scrs-serve/src/main.rs
index 13fe317..d712604 100644
--- a/scrs-serve/src/main.rs
+++ a/scrs-serve/src/main.rs
@@ -186,10 +186,18 @@

                let mut resp = resp
                    .header("Connection", "Close")
                    .header("Allow", "PUT, SOURCE")
                    .body(())
                    .unwrap();
                write_response(&mut stream, resp).await;
                    .header("Allow", "PUT, SOURCE");

                let expect_header = req
                    .headers()
                    .get("expect")
                    .map(http::HeaderValue::as_bytes)
                    .unwrap_or_default();
                if expect_header == b"100-continue" {
                    resp = resp.status(100);
                }

                write_response(&mut stream, resp.body(()).unwrap()).await;

                loop {
                    if stream.read_buf(&mut buffer).await.unwrap() == 0 {