@@ -55,30 +55,44 @@ namespace boost { namespace network { namespace http {
55
55
}
56
56
57
57
response const post (request request_, string_type const & content_type, string_type const & body_) {
58
+ if (!boost::empty (headers (request_)[" Content-Type" ]))
59
+ request_ << remove_header (" Content-Type" );
60
+
58
61
request_ << ::boost::network::body (body_)
62
+ << header (" Content-Type" , content_type)
59
63
<< 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);
62
64
return post (request_);
63
65
}
64
66
65
67
response const post (request const & request_, string_type const & body_) {
66
- return post (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
+ return post (request_, content_type, body_);
67
74
}
68
75
69
76
response const put (request const & request_) {
70
77
return pimpl->request_skeleton (request_, " PUT" , true );
71
78
}
72
79
73
80
response const put (request const & request_, string_type const & body_) {
74
- return put (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
+ return put (request_, content_type, body_);
75
87
}
76
88
77
89
response const put (request request_, string_type const & content_type, string_type const & body_) {
90
+ if (!boost::empty (headers (request_)[" Content-Type" ]))
91
+ request_ << remove_header (" Content-Type" );
92
+
78
93
request_ << ::boost::network::body (body_)
94
+ << header (" Content-Type" , content_type)
79
95
<< 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);
82
96
return put (request_);
83
97
}
84
98
0 commit comments