C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
|
HTTP client class, used to maintain a connection to an HTTP service for an extended session. More...
#include <http_client.h>
Public Member Functions | |
_ASYNCRTIMP | http_client (const uri &base_uri) |
Creates a new http_client connected to specified uri. More... | |
_ASYNCRTIMP | http_client (const uri &base_uri, const http_client_config &client_config) |
Creates a new http_client connected to specified uri. More... | |
~http_client () CPPREST_NOEXCEPT | |
Note the destructor doesn't necessarily close the connection and release resources. The connection is reference counted with the http_responses. More... | |
_ASYNCRTIMP const uri & | base_uri () const |
Gets the base URI. More... | |
_ASYNCRTIMP const http_client_config & | client_config () const |
Get client configuration object More... | |
void | add_handler (const std::function< pplx::task< http_response >(http_request, std::shared_ptr< http::http_pipeline_stage >)> &handler) |
Adds an HTTP pipeline stage to the client. More... | |
void | add_handler (const std::shared_ptr< http::http_pipeline_stage > &stage) |
Adds an HTTP pipeline stage to the client. More... | |
_ASYNCRTIMP pplx::task< http_response > | request (http_request request, const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const utility::string_t &path_query_fragment, const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const utility::string_t &path_query_fragment, const json::value &body_data, const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const utf8string &path_query_fragment, const utf8string &body_data, const utf8string &content_type="text/plain; charset=utf-8", const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8. More... | |
pplx::task< http_response > | request (const method &mtd, const utf8string &path_query_fragment, utf8string &&body_data, const utf8string &content_type="text/plain; charset=utf-8", const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8. More... | |
pplx::task< http_response > | request (const method &mtd, const utf16string &path_query_fragment, const utf16string &body_data, const utf16string &content_type=::utility::conversions::to_utf16string("text/plain"), const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-16 will perform conversion to UTF-8. More... | |
pplx::task< http_response > | request (const method &mtd, const utf8string &path_query_fragment, const utf8string &body_data, const pplx::cancellation_token &token) |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8. More... | |
pplx::task< http_response > | request (const method &mtd, const utf8string &path_query_fragment, utf8string &&body_data, const pplx::cancellation_token &token) |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8. More... | |
pplx::task< http_response > | request (const method &mtd, const utf16string &path_query_fragment, const utf16string &body_data, const pplx::cancellation_token &token) |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-16 will perform conversion to UTF-8. More... | |
pplx::task< http_response > | request (const method &mtd, const utility::string_t &path_query_fragment, const concurrency::streams::istream &body, const utility::string_t &content_type=_XPLATSTR("application/octet-stream"), const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const utility::string_t &path_query_fragment, const concurrency::streams::istream &body, const pplx::cancellation_token &token) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const utility::string_t &path_query_fragment, const concurrency::streams::istream &body, size_t content_length, const utility::string_t &content_type=_XPLATSTR("application/octet-stream"), const pplx::cancellation_token &token=pplx::cancellation_token::none()) |
Asynchronously sends an HTTP request. More... | |
pplx::task< http_response > | request (const method &mtd, const utility::string_t &path_query_fragment, const concurrency::streams::istream &body, size_t content_length, const pplx::cancellation_token &token) |
Asynchronously sends an HTTP request. More... | |
HTTP client class, used to maintain a connection to an HTTP service for an extended session.
web::http::client::http_client::http_client | ( | const uri & | base_uri | ) |
Creates a new http_client connected to specified uri.
base_uri | A string representation of the base uri to be used for all requests. Must start with either "http://" or "https://" |
web::http::client::http_client::http_client | ( | const uri & | base_uri, |
const http_client_config & | client_config | ||
) |
Creates a new http_client connected to specified uri.
base_uri | A string representation of the base uri to be used for all requests. Must start with either "http://" or "https://" |
client_config | The http client configuration object containing the possible configuration options to initialize the http_client . |
|
inline |
Note the destructor doesn't necessarily close the connection and release resources. The connection is reference counted with the http_responses.
|
inline |
Adds an HTTP pipeline stage to the client.
handler | A function object representing the pipeline stage. |
|
inline |
Adds an HTTP pipeline stage to the client.
stage | A shared pointer to a pipeline stage. |
const uri & web::http::client::http_client::base_uri | ( | ) | const |
Gets the base URI.
const http_client_config & web::http::client::http_client::client_config | ( | ) | const |
Get client configuration object
_ASYNCRTIMP pplx::task<http_response> web::http::client::http_client::request | ( | http_request | request, |
const pplx::cancellation_token & | token = pplx::cancellation_token::none() |
||
) |
Asynchronously sends an HTTP request.
request | Request to send. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body_data | The data to be used as the message body, represented using the json object library. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
content_type | A string holding the MIME type of the message body. |
body_data | String containing the text to use in the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
content_type | A string holding the MIME type of the message body. |
body_data | String containing the text to use in the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-16 will perform conversion to UTF-8.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
content_type | A string holding the MIME type of the message body. |
body_data | String containing the text to use in the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body_data | String containing the text to use in the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-8.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body_data | String containing the text to use in the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request with a string body. Assumes the character encoding of the string is UTF-16 will perform conversion to UTF-8.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body_data | String containing the text to use in the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body | An asynchronous stream representing the body data. |
content_type | A string holding the MIME type of the message body. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body | An asynchronous stream representing the body data. |
token | Cancellation token for cancellation of this request operation. |
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body | An asynchronous stream representing the body data. |
content_length | Size of the message body. |
content_type | A string holding the MIME type of the message body. |
token | Cancellation token for cancellation of this request operation. |
Winrt requires to provide content_length.
|
inline |
Asynchronously sends an HTTP request.
mtd | HTTP request method. |
path_query_fragment | String containing the path, query, and fragment, relative to the http_client's base URI. |
body | An asynchronous stream representing the body data. |
content_length | Size of the message body. |
token | Cancellation token for cancellation of this request operation. |
Winrt requires to provide content_length.