Permalink
Browse files

Update YaHTTP to v0.1.6

  • Loading branch information...
1 parent f56a6d4 commit 88dd8a7acbee0af87a24740fb88717744980e004 @cmouse cmouse committed Jun 18, 2015
Showing with 27 additions and 7 deletions.
  1. +8 −6 pdns/ext/yahttp/yahttp/reqresp.cpp
  2. +18 −0 pdns/ext/yahttp/yahttp/reqresp.hpp
  3. +1 −1 pdns/ext/yahttp/yahttp/router.hpp
@@ -188,6 +188,7 @@ 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()) {
@@ -198,16 +199,16 @@ namespace YaHTTP {
}
if ((headers.find("transfer-encoding") == headers.end() && kind == YAHTTP_TYPE_RESPONSE)) {
sendChunked = true;
- // write the header now
- os << "Transfer-Encoding: chunked" << "\r\n";
+ 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 = true;
- // write the header now
- os << "Transfer-Encoding: chunked" << "\r\n";
+ 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 = true;
+ sendChunked = hasBody;
}
}
}
@@ -216,6 +217,7 @@ namespace YaHTTP {
strstr_map_t::const_iterator iter = headers.begin();
while(iter != headers.end()) {
if (iter->first == "host" && kind != YAHTTP_TYPE_REQUEST) { iter++; continue; }
+ if (iter->first == "transfer-encoding" && sendChunked) { iter++; continue; }
std::string header = Utility::camelizeHeader(iter->first);
if (header == "Cookie" || header == "Set-Cookie") cookieSent = true;
os << Utility::camelizeHeader(iter->first) << ": " << iter->second << "\r\n";
@@ -206,6 +206,15 @@ namespace YaHTTP {
HTTPBase::initialize();
this->kind = YAHTTP_TYPE_RESPONSE;
}
+ void initialize(const HTTPBase& rhs) {
+ HTTPBase::initialize();
+ this->kind = YAHTTP_TYPE_RESPONSE;
+ // copy SOME attributes
+ this->url = rhs.url;
+ this->method = rhs.method;
+ this->jar = rhs.jar;
+ this->version = rhs.version;
+ }
friend std::ostream& operator<<(std::ostream& os, const Response &resp);
friend std::istream& operator>>(std::istream& is, Response &resp);
};
@@ -226,6 +235,15 @@ namespace YaHTTP {
HTTPBase::initialize();
this->kind = YAHTTP_TYPE_REQUEST;
}
+ void initialize(const HTTPBase& rhs) {
+ HTTPBase::initialize();
+ this->kind = YAHTTP_TYPE_REQUEST;
+ // copy SOME attributes
+ this->url = rhs.url;
+ this->method = rhs.method;
+ this->jar = rhs.jar;
+ this->version = rhs.version;
+ }
void setup(const std::string& method, const std::string& url) {
this->url.parse(url);
this->headers["host"] = this->url.host;
@@ -17,7 +17,7 @@ namespace funcptr = std;
namespace funcptr = boost;
#define HAVE_CPP_FUNC_PTR
#else
-#warn "You need to configure with boost or have C++11 capable compiler for router"
+#warning "You need to configure with boost or have C++11 capable compiler for router"
#endif
#endif

0 comments on commit 88dd8a7

Please sign in to comment.