diff options
author | ipknHama <ipknhama@gmail.com> | 2014-05-02 21:54:25 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-07-09 14:08:40 +0900 |
commit | c19eed028535b847489ca03a43fc4dc42e7451cf (patch) | |
tree | 620867e8b8edbeefea0ac6a56ed7b4ab6635c884 /http_connection.h | |
parent | 23f9b528586610c43be8bccbe50e978afd47dfec (diff) | |
download | crow-c19eed028535b847489ca03a43fc4dc42e7451cf.tar.gz crow-c19eed028535b847489ca03a43fc4dc42e7451cf.zip |
add support for "Expect: 100-continue"
Diffstat (limited to 'http_connection.h')
-rw-r--r-- | http_connection.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/http_connection.h b/http_connection.h index 5da294d..867196c 100644 --- a/http_connection.h +++ b/http_connection.h @@ -34,6 +34,18 @@ namespace crow do_read(); } + void handle_header() + { + // HTTP 1.1 Expect: 100-continue + if (parser_.check_version(1, 1) && parser_.headers.count("expect") && parser_.headers["expect"] == "100-continue") + { + buffers_.clear(); + static std::string expect_100_continue = "HTTP/1.1 100 Continue\r\n\r\n"; + buffers_.emplace_back(expect_100_continue.data(), expect_100_continue.size()); + do_write(); + } + } + void handle() { static std::unordered_map<int, std::string> statusCodes = { @@ -61,13 +73,13 @@ namespace crow bool is_invalid_request = false; request req = parser_.to_request(); - if (parser_.http_major == 1 && parser_.http_minor == 0) + if (parser_.check_version(1, 0)) { // HTTP/1.0 if (!(req.headers.count("connection") && boost::iequals(req.headers["connection"],"Keep-Alive"))) close_connection_ = true; } - else if (parser_.http_major == 1 && parser_.http_minor == 1) + else if (parser_.check_version(1, 1)) { // HTTP/1.1 if (req.headers.count("connection") && req.headers["connection"] == "close") |