- Notifications
You must be signed in to change notification settings - Fork425
example: send response content-length as part of http header from server#808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -189,7 +189,7 @@ struct connection_handler { | ||
/// @param [in] conn Connection object | ||
/// | ||
void operator()(server::request const& req, const server::connection_ptr& conn) { | ||
std::map<std::string, std::string> headers = { | ||
{"Connection","close"}, | ||
{"Content-Length", "0"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Why do you need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This was the reason for#681 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think I understand now, that you want to always define this for every new response. That makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think this map really ought to not be static, unless you're going to make copies of it for every instance of this handler -- note that there could be multiple threads accessing this map, and updating it on the fly will cause all sorts of threading issues. Aside from that, the other changes look good. | ||
{"Content-Type", "text/plain"} | ||
@@ -225,8 +225,8 @@ struct connection_handler { | ||
conn->write(err); | ||
} | ||
} else { | ||
staticconstexpr charbody[] ="Only path allowed is /upload"; | ||
headers["Content-Length"] = std::to_string(sizeof(body)); | ||
conn->set_status(server::connection::bad_request); | ||
conn->set_headers(headers); | ||
conn->write(body); | ||