Server::Response::write convenience functions no longer write Content-Length if close_connection_after_response is set. Also added some doxygen comments
This commit is contained in:
parent
98d9617244
commit
bf379ebcba
2 changed files with 6 additions and 1 deletions
|
|
@ -68,7 +68,7 @@ namespace SimpleWeb {
|
|||
|
||||
*this << field.first << ": " << field.second << "\r\n";
|
||||
}
|
||||
if(!content_length_written && !chunked_transfer_encoding)
|
||||
if(!content_length_written && !chunked_transfer_encoding && !close_connection_after_response)
|
||||
*this << "Content-Length: " << size << "\r\n\r\n";
|
||||
else
|
||||
*this << "\r\n";
|
||||
|
|
@ -78,6 +78,7 @@ namespace SimpleWeb {
|
|||
return streambuf.size();
|
||||
}
|
||||
|
||||
/// Write directly to stream buffer using std::ostream::write
|
||||
void write(const char_type *ptr, std::streamsize n) {
|
||||
std::ostream::write(ptr, n);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ typedef std::unordered_multimap<std::string, std::string, CaseInsensitiveHash, C
|
|||
/// Percent encoding and decoding
|
||||
class Percent {
|
||||
public:
|
||||
/// Returns percent-encoded string
|
||||
static std::string encode(const std::string &value) {
|
||||
static auto hex_chars = "0123456789ABCDEF";
|
||||
|
||||
|
|
@ -68,6 +69,7 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
/// Returns percent-decoded string
|
||||
static std::string decode(const std::string &value) {
|
||||
std::string result;
|
||||
result.reserve(value.size() / 3 + (value.size() % 3)); // minimum size of result
|
||||
|
|
@ -90,8 +92,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/// Query string creation and parsing
|
||||
class QueryString {
|
||||
public:
|
||||
/// Returns query string created from given field names and values
|
||||
static std::string create(const CaseInsensitiveMultimap &fields) {
|
||||
std::string result;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue