@@ -120,26 +120,8 @@ class basic_client_facade {
120
120
body_callback_function_type body_handler = body_callback_function_type(),
121
121
body_generator_function_type body_generator =
122
122
body_generator_function_type()) {
123
- if (body !=string_type ()) {
124
- request <<remove_header (" Content-Length" )
125
- <<header (" Content-Length" ,std::to_string (body.size ()))
126
- <<boost::network::body (body);
127
- }
128
- typename headers_range<basic_request<Tag> >::type content_type_headers =
129
- headers (request)[" Content-Type" ];
130
- if (content_type !=string_type ()) {
131
- if (!boost::empty (content_type_headers))
132
- request <<remove_header (" Content-Type" );
133
- request <<header (" Content-Type" , content_type);
134
- }else {
135
- if (boost::empty (content_type_headers)) {
136
- typedef typename char_<Tag>::type char_type;
137
- static char_typeconst content_type[] =" x-application/octet-stream" ;
138
- request <<header (" Content-Type" , content_type);
139
- }
140
- }
141
- return pimpl->request_skeleton (request," POST" ,true , body_handler,
142
- body_generator);
123
+ return perform_request (request," POST" , body, content_type,
124
+ body_handler, body_generator);
143
125
}
144
126
145
127
/* *
@@ -225,26 +207,8 @@ class basic_client_facade {
225
207
body_callback_function_type body_handler = body_callback_function_type(),
226
208
body_generator_function_type body_generator =
227
209
body_generator_function_type()) {
228
- if (body !=string_type ()) {
229
- request <<remove_header (" Content-Length" )
230
- <<header (" Content-Length" ,std::to_string (body.size ()))
231
- <<boost::network::body (body);
232
- }
233
- typename headers_range<basic_request<Tag> >::type content_type_headers =
234
- headers (request)[" Content-Type" ];
235
- if (content_type !=string_type ()) {
236
- if (!boost::empty (content_type_headers))
237
- request <<remove_header (" Content-Type" );
238
- request <<header (" Content-Type" , content_type);
239
- }else {
240
- if (boost::empty (content_type_headers)) {
241
- typedef typename char_<Tag>::type char_type;
242
- static char_typeconst content_type[] =" x-application/octet-stream" ;
243
- request <<header (" Content-Type" , content_type);
244
- }
245
- }
246
- return pimpl->request_skeleton (request," PUT" ,true , body_handler,
247
- body_generator);
210
+ return perform_request (request," PUT" , body, content_type,
211
+ body_handler, body_generator);
248
212
}
249
213
250
214
/* *
@@ -284,6 +248,117 @@ class basic_client_facade {
284
248
return put (request, body,string_type (), body_handler, body_generator);
285
249
}
286
250
251
+ /* *
252
+ * Perform a PATCH request.
253
+ *
254
+ * @param[in] request A copy of the request object including the URI and
255
+ * headers.
256
+ * @param[in] body The whole contents of the body. If provided, this overrides
257
+ * the body in the `request`.
258
+ * @param[in] content_type The content type for the request. This overrides
259
+ * the content type in the `request`.
260
+ * @param[in] body_handler The callback invoked for parts of the response body
261
+ * as they come in.
262
+ * @param[in] body_generator If provided, is invoked to generate parts of the
263
+ * request's body as it is being sent.
264
+ * @returns A response object.
265
+ * @throws std::exception May throw exceptions on errors, derived from
266
+ * `std::exception`.
267
+ */
268
+ responsepatch (
269
+ request request, string_typeconst & body = string_type(),
270
+ string_typeconst & content_type = string_type(),
271
+ body_callback_function_type body_handler = body_callback_function_type(),
272
+ body_generator_function_type body_generator =
273
+ body_generator_function_type()) {
274
+ return perform_request (request," PATCH" , body, content_type,
275
+ body_handler, body_generator);
276
+ }
277
+
278
+ /* *
279
+ * Perform a PATCH request.
280
+ *
281
+ * @param[in] request The request including the URI and headers.
282
+ * @param[in] callback If provided, the function to call for parts of the
283
+ * response's body as they come in.
284
+ * @param[in] body_generator The function to call to generate part of the body
285
+ * while the request is being performed.
286
+ * @returns A response object.
287
+ * @throws std::exception May throw exceptions derived from std::exception in
288
+ * case of errors.
289
+ */
290
+ responsepatch (requestconst & request, body_callback_function_type callback,
291
+ body_generator_function_type body_generator =
292
+ body_generator_function_type ()) {
293
+ return patch (request,string_type (),string_type (), callback, body_generator);
294
+ }
295
+
296
+ /* *
297
+ * Perform a PATCH request.
298
+ *
299
+ * @param[in] request The request object including the URI and headers.
300
+ * @param[in] body The whole contents of the body.
301
+ * @param[in] body_handler The callback invoked for parts of the response body
302
+ * as they come in.
303
+ * @param[in] body_generator If provided, is invoked to generate parts of the
304
+ * request's body as it is being sent.
305
+ * @returns A response object.
306
+ * @throws std::exception May throw exceptions on errors, derived from
307
+ * `std::exception`.
308
+ */
309
+ responsepatch (requestconst & request, string_type body,
310
+ body_callback_function_type body_handler,
311
+ body_generator_function_type body_generator = {}) {
312
+ return patch (request, body,string_type (), body_handler, body_generator);
313
+ }
314
+
315
+ /* *
316
+ * Perform a request.
317
+ *
318
+ * @param[in] request A copy of the request object including the URI and
319
+ * headers.
320
+ * @param[in] method The HTTP method
321
+ * @param[in] body The whole contents of the body. If provided, this overrides
322
+ * the body in the `request`.
323
+ * @param[in] content_type The content type for the request. This overrides
324
+ * the content type in the `request`.
325
+ * @param[in] body_handler The callback invoked for parts of the response body
326
+ * as they come in.
327
+ * @param[in] body_generator If provided, is invoked to generate parts of the
328
+ * request's body as it is being sent.
329
+ * @returns A response object.
330
+ * @throws std::exception May throw exceptions on errors, derived from
331
+ * `std::exception`.
332
+ */
333
+ responseperform_request (request request, string_typeconst & method,
334
+ string_typeconst & body = string_type(),
335
+ string_typeconst & content_type = string_type(),
336
+ body_callback_function_type body_handler =
337
+ body_callback_function_type(),
338
+ body_generator_function_type body_generator =
339
+ body_generator_function_type()) {
340
+ if (body !=string_type ()) {
341
+ request <<remove_header (" Content-Length" )
342
+ <<header (" Content-Length" ,std::to_string (body.size ()))
343
+ <<boost::network::body (body);
344
+ }
345
+ typename headers_range<basic_request<Tag> >::type content_type_headers =
346
+ headers (request)[" Content-Type" ];
347
+ if (content_type !=string_type ()) {
348
+ if (!boost::empty (content_type_headers))
349
+ request <<remove_header (" Content-Type" );
350
+ request <<header (" Content-Type" , content_type);
351
+ }else {
352
+ if (boost::empty (content_type_headers)) {
353
+ typedef typename char_<Tag>::type char_type;
354
+ static char_typeconst content_type[] =" x-application/octet-stream" ;
355
+ request <<header (" Content-Type" , content_type);
356
+ }
357
+ }
358
+ return pimpl->request_skeleton (request, method,true , body_handler,
359
+ body_generator);
360
+ }
361
+
287
362
/* *
288
363
* Perform a DELETE request.
289
364
*