Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
deanberris merged 3 commits intocpp-netlib:0.13-releasefromcarun:fix-content-length
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Implemented review comments.
  • Loading branch information
@carun
carun committedJan 23, 2018
commit7a0cbe77333e2e342e9d71f47c7eadc3a7512c5e
6 changes: 3 additions & 3 deletionslibs/network/example/http/async_server_file_upload.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ struct connection_handler {
/// @param [in] conn Connection object
///
void operator()(server::request const& req, const server::connection_ptr& conn) {
staticstd::map<std::string, std::string> headers = {
std::map<std::string, std::string> headers = {
{"Connection","close"},
{"Content-Length", "0"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why do you need this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This was the reason for#681

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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"}
Expand DownExpand Up@@ -225,8 +225,8 @@ struct connection_handler {
conn->write(err);
}
} else {
staticstd::stringbody("Only path allowed is /upload");
headers["Content-Length"] = std::to_string(body.size());
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);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ void process_request(work_queue& queue) {
// some heavy work!
std::this_thread::sleep_for(std::chrono::seconds(10));

staticstd::map<std::string, std::string> headers = {
std::map<std::string, std::string> headers = {
{"Content-Length", "0"},
{"Content-Type", "text/plain"},
};
Expand Down
2 changes: 1 addition & 1 deletionlibs/network/example/http/hello_world_server.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ struct hello_world {
std::ostringstream data;
data << "Hello, " << ip << ':' << port << '!';

staticstd::map<std::string, std::string> headers = {
std::map<std::string, std::string> headers = {
{"Content-Length", "0"},
{"Content-Type", "text/plain"},
};
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp