]> granicus.if.org Git - pdns/commitdiff
Update YaHTTP to v0.1.6
authorAki Tuomi <cmouse@desteem.org>
Thu, 18 Jun 2015 14:34:09 +0000 (17:34 +0300)
committerAki Tuomi <cmouse@desteem.org>
Fri, 19 Jun 2015 08:01:07 +0000 (11:01 +0300)
pdns/ext/yahttp/yahttp/reqresp.cpp
pdns/ext/yahttp/yahttp/reqresp.hpp
pdns/ext/yahttp/yahttp/router.hpp

index 07a408a349cf987458c9178ff9298d14d2aa6762..eee72804bf82acf8777bb340d399bd6fb0d360d6 100644 (file)
@@ -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";
index 8916c8e71080f38d809b0e88dc3a07d58945aeea..9419d556f79577faa56a29f8bb58367eff40be39 100644 (file)
@@ -206,6 +206,15 @@ public:
       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 @@ public:
       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;
index 60bd21725dd8c8f56e43e723ee72809cb4845e70..915155f8a603f3afead9acd124076c892843c438 100644 (file)
@@ -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