From d3acb91530129a9b3cd4290397a7893139121f6d Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 26 Apr 2016 14:00:59 +0200 Subject: [PATCH] Update yahttp, closes #3723 --- ext/yahttp/README.md | 7 +++++++ ext/yahttp/yahttp/reqresp.cpp | 10 +--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/yahttp/README.md b/ext/yahttp/README.md index d74aed4f6..7cd9e3562 100644 --- a/ext/yahttp/README.md +++ b/ext/yahttp/README.md @@ -5,11 +5,18 @@ YaHTTP aims to be a pure http request/response parser that has no IO ties. It is [![Build Status](https://travis-ci.org/cmouse/yahttp.svg?branch=master)](https://travis-ci.org/cmouse/yahttp) [![Coverity Scan Build Status](https://scan.coverity.com/projects/2161/badge.svg)](https://scan.coverity.com/projects/2161) +[![Coverage Status](https://coveralls.io/repos/cmouse/yahttp/badge.svg?branch=master%0A)](https://coveralls.io/r/cmouse/yahttp?branch=master%0A) WARNINGS -------- If you are upgrading from version before May 02, 2014 - *PLEASE BE SURE TO CHECK THAT EVERYTHING WORKS AS EXPECTED*. There has been complete overhaul of the library and many things have changed. +NOTES +----- +Do not use resp = req, or resp(req) to build the response object, despite it being supported. This will cause request headers to get duplicated. Also, you *must* set response#version to request#version if you intend to support older than HTTP/1.1 clients. Set response#status to at least 200, it won't be done for you. No Server or Product token is sent either, you can add those if you want. + +If you do not want to send chunked responses, set content-length header. Setting this header will always disable chunked responses. This will also happen if you downgrade your responses to version 10 or 9. + Integration guide ----------------- diff --git a/ext/yahttp/yahttp/reqresp.cpp b/ext/yahttp/yahttp/reqresp.cpp index 3dd78483f..cc992859b 100644 --- a/ext/yahttp/yahttp/reqresp.cpp +++ b/ext/yahttp/yahttp/reqresp.cpp @@ -190,7 +190,6 @@ namespace YaHTTP { bool cookieSent = false; bool sendChunked = false; - bool hasBody = true; if (this->version > 10) { // 1.1 or better if (headers.find("content-length") == headers.end()) { @@ -204,14 +203,7 @@ namespace YaHTTP { os << "Transfer-Encoding: chunked\r\n"; } } else { - hasBody = (headers.find("content-length")->second != "0"); - if ((headers.find("transfer-encoding") == headers.end() && kind == YAHTTP_TYPE_RESPONSE)) { - sendChunked = hasBody; - if (sendChunked) - os << "Transfer-Encoding: chunked\r\n"; - } else if (headers.find("transfer-encoding") != headers.end() && headers.find("transfer-encoding")->second == "chunked") { - sendChunked = hasBody; - } + sendChunked = false; } } -- 2.40.0