@@ -461,19 +461,65 @@ class http_client
461
461
}
462
462
463
463
// / <summary>
464
- // / Asynchronously sends an HTTP request.
464
+ // / Asynchronously sends an HTTP request with a string body. Assumes the
465
+ // / character encoding of the string is UTF-8.
466
+ // / </summary>
467
+ // / <param name="mtd">HTTP request method.</param>
468
+ // / <param name="path_query_fragment">String containing the path, query, and fragment, relative to the http_client's base URI.</param>
469
+ // / <param name="content_type">A string holding the MIME type of the message body.</param>
470
+ // / <param name="body_data">String containing the text to use in the message body.</param>
471
+ // / <param name="token">Cancellation token for cancellation of this request operation.</param>
472
+ // / <returns>An asynchronous operation that is completed once a response from the request is received.</returns>
473
+ pplx::task<http_response> request (
474
+ const method &mtd,
475
+ const utf8string &path_query_fragment,
476
+ const utf8string &body_data,
477
+ const utf8string &content_type = " text/plain; charset=utf-8" ,
478
+ const pplx::cancellation_token &token = pplx::cancellation_token::none())
479
+ {
480
+ http_request msg (mtd);
481
+ msg.set_request_uri (::utility::conversions::to_string_t (path_query_fragment));
482
+ msg.set_body (body_data, content_type);
483
+ return request (msg, token);
484
+ }
485
+
486
+ // / <summary>
487
+ // / Asynchronously sends an HTTP request with a string body. Assumes the
488
+ // / character encoding of the string is UTF-8.
489
+ // / </summary>
490
+ // / <param name="mtd">HTTP request method.</param>
491
+ // / <param name="path_query_fragment">String containing the path, query, and fragment, relative to the http_client's base URI.</param>
492
+ // / <param name="content_type">A string holding the MIME type of the message body.</param>
493
+ // / <param name="body_data">String containing the text to use in the message body.</param>
494
+ // / <param name="token">Cancellation token for cancellation of this request operation.</param>
495
+ // / <returns>An asynchronous operation that is completed once a response from the request is received.</returns>
496
+ pplx::task<http_response> request (
497
+ const method &mtd,
498
+ const utf8string &path_query_fragment,
499
+ utf8string &&body_data,
500
+ const utf8string &content_type = " text/plain; charset=utf-8" ,
501
+ const pplx::cancellation_token &token = pplx::cancellation_token::none())
502
+ {
503
+ http_request msg (mtd);
504
+ msg.set_request_uri (::utility::conversions::to_string_t (path_query_fragment));
505
+ msg.set_body (std::move (body_data), content_type);
506
+ return request (msg, token);
507
+ }
508
+
509
+ // / <summary>
510
+ // / Asynchronously sends an HTTP request with a string body. Assumes the
511
+ // / character encoding of the string is UTF-16 will perform conversion to UTF-8.
465
512
// / </summary>
466
513
// / <param name="mtd">HTTP request method.</param>
467
514
// / <param name="path_query_fragment">String containing the path, query, and fragment, relative to the http_client's base URI.</param>
468
515
// / <param name="content_type">A string holding the MIME type of the message body.</param>
469
516
// / <param name="body_data">String containing the text to use in the message body.</param>
470
517
// / <param name="token">Cancellation token for cancellation of this request operation.</param>
471
518
// / <returns>An asynchronous operation that is completed once a response from the request is received.</returns>
472
- // TODO overload???Not sure...
473
519
pplx::task<http_response> request (
474
520
const method &mtd,
475
521
const utility::string_t &path_query_fragment,
476
- const utility:: string_t &body_data,
522
+ const utf16string &body_data,
477
523
const utility::string_t &content_type = _XPLATSTR(" text/plain" ),
478
524
const pplx::cancellation_token &token = pplx::cancellation_token::none())
479
525
{
@@ -484,18 +530,57 @@ class http_client
484
530
}
485
531
486
532
// / <summary>
487
- // / Asynchronously sends an HTTP request.
533
+ // / Asynchronously sends an HTTP request with a string body. Assumes the
534
+ // / character encoding of the string is UTF-8.
488
535
// / </summary>
489
536
// / <param name="mtd">HTTP request method.</param>
490
537
// / <param name="path_query_fragment">String containing the path, query, and fragment, relative to the http_client's base URI.</param>
491
538
// / <param name="body_data">String containing the text to use in the message body.</param>
492
539
// / <param name="token">Cancellation token for cancellation of this request operation.</param>
493
540
// / <returns>An asynchronous operation that is completed once a response from the request is received.</returns>
494
- // TODO overload not usre???
495
541
pplx::task<http_response> request (
496
542
const method &mtd,
497
- const utility::string_t &path_query_fragment,
498
- const utility::string_t &body_data,
543
+ const utf8string &path_query_fragment,
544
+ const utf8string &body_data,
545
+ const pplx::cancellation_token &token)
546
+ {
547
+ return request (mtd, path_query_fragment, body_data, " text/plain; charset=utf-8" , token);
548
+ }
549
+
550
+ // / <summary>
551
+ // / Asynchronously sends an HTTP request with a string body. Assumes the
552
+ // / character encoding of the string is UTF-8.
553
+ // / </summary>
554
+ // / <param name="mtd">HTTP request method.</param>
555
+ // / <param name="path_query_fragment">String containing the path, query, and fragment, relative to the http_client's base URI.</param>
556
+ // / <param name="body_data">String containing the text to use in the message body.</param>
557
+ // / <param name="token">Cancellation token for cancellation of this request operation.</param>
558
+ // / <returns>An asynchronous operation that is completed once a response from the request is received.</returns>
559
+ pplx::task<http_response> request (
560
+ const method &mtd,
561
+ const utf8string &path_query_fragment,
562
+ utf8string &&body_data,
563
+ const pplx::cancellation_token &token)
564
+ {
565
+ http_request msg (mtd);
566
+ msg.set_request_uri (::utility::conversions::to_string_t (path_query_fragment));
567
+ msg.set_body (std::move (body_data), " text/plain; charset=utf-8" );
568
+ return request (msg, token);
569
+ }
570
+
571
+ // / <summary>
572
+ // / Asynchronously sends an HTTP request with a string body. Assumes
573
+ // / the character encoding of the string is UTF-16 will perform conversion to UTF-8.
574
+ // / </summary>
575
+ // / <param name="mtd">HTTP request method.</param>
576
+ // / <param name="path_query_fragment">String containing the path, query, and fragment, relative to the http_client's base URI.</param>
577
+ // / <param name="body_data">String containing the text to use in the message body.</param>
578
+ // / <param name="token">Cancellation token for cancellation of this request operation.</param>
579
+ // / <returns>An asynchronous operation that is completed once a response from the request is received.</returns>
580
+ pplx::task<http_response> request (
581
+ const method &mtd,
582
+ const utf16string &path_query_fragment,
583
+ const utf16string &body_data,
499
584
const pplx::cancellation_token &token)
500
585
{
501
586
return request (mtd, path_query_fragment, body_data, _XPLATSTR (" text/plain" ), token);
0 commit comments