summaryrefslogtreecommitdiff
path: root/src/proxy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/proxy.cc')
-rw-r--r--src/proxy.cc30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/proxy.cc b/src/proxy.cc
index 3909541..5eca4fb 100644
--- a/src/proxy.cc
+++ b/src/proxy.cc
@@ -822,27 +822,6 @@ bool ProxyImpl::base_event(BaseClient* client, uint8_t events,
return true;
}
-inline char lower_ascii(char c) {
- return (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
-}
-
-bool lower_equal(char const* data, size_t start, size_t end,
- std::string const& str) {
- assert(start <= end);
- if (str.size() != end - start) return false;
- for (auto i = str.begin(); start < end; ++start, ++i) {
- if (lower_ascii(*i) != lower_ascii(data[start])) return false;
- }
- return true;
-}
-
-bool header_token_eq(std::string const& value, std::string const& token) {
- if (value.empty()) return false;
- auto pos = value.find(';');
- if (pos == std::string::npos) pos = value.size();
- return lower_equal(value.data(), 0, pos, token);
-}
-
void ProxyImpl::client_remote_error(size_t index, uint16_t error) {
auto& client = clients_[index];
if (client.remote_state > CONNECTED) {
@@ -1014,8 +993,13 @@ void ProxyImpl::client_event(size_t index, int fd, uint8_t events) {
bool setup_content(Http const* http, Content* content) {
assert(content->type == CONTENT_NONE);
- std::string te = http->first_header("transfer-encoding");
- if (te.empty() || header_token_eq(te, "identity")) {
+ auto iter = http->header_tokens("transfer-encoding");
+ bool chunked = false;
+ while (iter->valid()) {
+ chunked = iter->token_equal("chunked");
+ iter->next();
+ }
+ if (!chunked) {
std::string len = http->first_header("content-length");
if (len.empty()) {
content->type = CONTENT_CLOSE;