Skip to content

Commit

Permalink
Update YaHTTP to v0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Jun 19, 2015
1 parent f56a6d4 commit 88dd8a7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pdns/ext/yahttp/yahttp/reqresp.cpp
Expand Up @@ -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()) {
Expand All @@ -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;
}
}
}
Expand All @@ -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";
Expand Down
18 changes: 18 additions & 0 deletions pdns/ext/yahttp/yahttp/reqresp.hpp
Expand Up @@ -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);
};
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pdns/ext/yahttp/yahttp/router.hpp
Expand Up @@ -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

Expand Down

0 comments on commit 88dd8a7

Please sign in to comment.