@@ -40,30 +40,44 @@ namespace boost { namespace network { namespace http {
40
40
}
41
41
42
42
response const post (request request_, string_type const & content_type, string_type const & body_) {
43
+ if (!boost::empty (headers (request_)[" Content-Type" ]))
44
+ request_ << remove_header (" Content-Type" );
45
+
43
46
request_ << ::boost::network::body (body_)
47
+ << header (" Content-Type" , content_type)
44
48
<< header (" Content-Length" , boost::lexical_cast<string_type>(body_.size ()));
45
- if (!boost::empty (headers (request_)[" Content-Type" ]))
46
- request_ << header (" Content-Type" , content_type);
47
49
return post (request_);
48
50
}
49
51
50
52
response const post (request const & request_, string_type const & body_) {
51
- return post (request_, " x-application/octet-stream" , body_);
53
+ string_type content_type = " x-application/octet-stream" ;
54
+ typename headers_range<request>::type content_type_headers =
55
+ headers (request_)[" Content-Type" ];
56
+ if (!boost::empty (content_type_headers))
57
+ content_type = boost::begin (content_type_headers)->second ;
58
+ return post (request_, content_type, body_);
52
59
}
53
60
54
61
response const put (request const & request_) {
55
62
return static_cast <Derived*>(this )->request_skeleton (request_, " PUT" , true );
56
63
}
57
64
58
65
response const put (request const & request_, string_type const & body_) {
59
- return put (request_, " x-application/octet-stream" , body_);
66
+ string_type content_type = " x-application/octet-stream" ;
67
+ typename headers_range<request>::type content_type_headers =
68
+ headers (request_)[" Content-Type" ];
69
+ if (!boost::empty (content_type_headers))
70
+ content_type = boost::begin (content_type_headers)->second ;
71
+ return put (request_, content_type, body_);
60
72
}
61
73
62
74
response const put (request request_, string_type const & content_type, string_type const & body_) {
75
+ if (!boost::empty (headers (request_)[" Content-Type" ]))
76
+ request_ << remove_header (" Content-Type" );
77
+
63
78
request_ << ::boost::network::body (body_)
79
+ << header (" Content-Type" , content_type)
64
80
<< header (" Content-Length" , boost::lexical_cast<string_type>(body_.size ()));
65
- if (!boost::empty (headers (request_)[" Content-Type" ]))
66
- request_ << header (" Content-Type" , content_type);
67
81
return put (request_);
68
82
}
69
83
0 commit comments