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

Commit862f614

Browse files
committed
Addendum to#35
This fix improves upon the earlier commit to make the implementation more predictableand semantically consistent with the interface for both the put and post methods.
1 parenta623730 commit862f614

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

‎boost/network/protocol/http/client/facade.hpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,44 @@ namespace boost { namespace network { namespace http {
5555
}
5656

5757
responseconstpost (request request_, string_typeconst & content_type, string_typeconst & body_) {
58+
if (!boost::empty(headers(request_)["Content-Type"]))
59+
request_ <<remove_header("Content-Type");
60+
5861
request_ << ::boost::network::body(body_)
62+
<<header("Content-Type", content_type)
5963
<<header("Content-Length", boost::lexical_cast<string_type>(body_.size()));
60-
if (!boost::empty(headers(request_)["Content-Type"]))
61-
request_ <<header("Content-Type", content_type);
6264
returnpost(request_);
6365
}
6466

6567
responseconstpost (requestconst & request_, string_typeconst & body_) {
66-
returnpost(request_,"x-application/octet-stream", body_);
68+
string_type content_type ="x-application/octet-stream";
69+
typename headers_range<request>::type content_type_headers =
70+
headers(request_)["Content-Type"];
71+
if (!boost::empty(content_type_headers))
72+
content_type =boost::begin(content_type_headers)->second;
73+
returnpost(request_, content_type, body_);
6774
}
6875

6976
responseconstput (requestconst & request_) {
7077
return pimpl->request_skeleton(request_,"PUT",true);
7178
}
7279

7380
responseconstput (requestconst & request_, string_typeconst & body_) {
74-
returnput(request_,"x-application/octet-stream", body_);
81+
string_type content_type ="x-application/octet-stream";
82+
typename headers_range<request>::type content_type_headers =
83+
headers(request_)["Content-Type"];
84+
if (!boost::empty(content_type_headers))
85+
content_type =boost::begin(content_type_headers)->second;
86+
returnput(request_, content_type, body_);
7587
}
7688

7789
responseconstput (request request_, string_typeconst & content_type, string_typeconst & body_) {
90+
if (!boost::empty(headers(request_)["Content-Type"]))
91+
request_ <<remove_header("Content-Type");
92+
7893
request_ << ::boost::network::body(body_)
94+
<<header("Content-Type", content_type)
7995
<<header("Content-Length", boost::lexical_cast<string_type>(body_.size()));
80-
if (!boost::empty(headers(request_)["Content-Type"]))
81-
request_ <<header("Content-Type", content_type);
8296
returnput(request_);
8397
}
8498

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp