Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Client can now send chunked transfer encoded content
Browse files Browse the repository at this point in the history
  • Loading branch information
eidheim committed Nov 19, 2017
1 parent 0c8da10 commit 4f67773
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions client_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,14 @@ namespace SimpleWeb {
};

std::ostream write_stream(session->request_streambuf.get());
if(content.size() > 0)
write_stream << "Content-Length: " << content.size() << "\r\n";
if(content.size() > 0) {
auto header_it = header.find("Content-Length");
if(header_it == header.end()) {
header_it = header.find("Transfer-Encoding");
if(header_it == header.end() || header_it->second != "chunked")
write_stream << "Content-Length: " << content.size() << "\r\n";
}
}
write_stream << "\r\n"
<< content;

Expand Down Expand Up @@ -314,8 +320,14 @@ namespace SimpleWeb {
auto content_length = content.tellg();
content.seekg(0, std::ios::beg);
std::ostream write_stream(session->request_streambuf.get());
if(content_length > 0)
write_stream << "Content-Length: " << content_length << "\r\n";
if(content_length > 0) {
auto header_it = header.find("Content-Length");
if(header_it == header.end()) {
header_it = header.find("Transfer-Encoding");
if(header_it == header.end() || header_it->second != "chunked")
write_stream << "Content-Length: " << content_length << "\r\n";
}
}
write_stream << "\r\n";
if(content_length > 0)
write_stream << content.rdbuf();
Expand Down

0 comments on commit 4f67773

Please sign in to comment.