|
olp-cpp-sdk
1.23.1
|
An HTTP client abstraction. More...
#include <Network.h>

Classes | |
| struct | Statistics |
| Network statistics for a specific bucket. More... | |
Public Types | |
| using | Callback = std::function< void(NetworkResponse response)> |
| The callback that is called when the request is processed or canceled. | |
| using | HeaderCallback = std::function< void(std::string key, std::string value)> |
| The callback that is called when a header is received. | |
| using | DataCallback = std::function< void(const std::uint8_t *data, std::uint64_t offset, std::size_t length)> |
| The callback that is called when a chunk of data is received. | |
| using | Payload = std::shared_ptr< std::ostream > |
| The request and response payload type. | |
Public Member Functions | |
| virtual SendOutcome | Send (NetworkRequest request, Payload payload, Callback callback, HeaderCallback header_callback=nullptr, DataCallback data_callback=nullptr)=0 |
| Sends the network request. More... | |
| virtual void | Cancel (RequestId id)=0 |
Cancels the request associated with the given RequestId. More... | |
| virtual void | SetDefaultHeaders (Headers headers) |
| Sets the default network headers. More... | |
| virtual void | SetCurrentBucket (uint8_t bucket_id) |
| Sets the current bucket statistics. More... | |
| virtual Statistics | GetStatistics (uint8_t bucket_id=0) |
| Gets the statistics for a bucket. More... | |
An HTTP client abstraction.
|
pure virtual |
Cancels the request associated with the given RequestId.
When the request is canceled, the user receives a final callback with an appropriate NetworkResponse marked as canceled as illustrated in the following code snippet:
RequestId does not match any pending requests, no operations will be performed, and no callbacks will be called.| [in] | id | The unique ID of the request that you want to cancel. |
Implemented in olp::http::HarCaptureAdapter.
|
virtual |
Gets the statistics for a bucket.
By default, it returns the statistics for the default bucket and the ID that equals 0.
| [in] | bucket_id | The bucket ID. |
|
pure virtual |
Sends the network request.
| [in] | request | The request that is sent. |
| [in] | payload | The stream used to store the response payload data. |
| [in] | callback | The callback that is called when the request is fully processed or canceled. After this call, no more callbacks are triggered, and you can consider the request as done. |
| [in] | header_callback | The callback that is called when an HTTP header is received. Each HTTP header entry results in a callback. |
| [in] | data_callback | The callback that is called when a chunk of data is received. You can trigger triggered multiple times before the final Callback call. |
SendOutcome that represents either a valid RequestId as the unique request identifier or an ErrorCode in case of failure. In case of failure, no callbacks are triggered. Implemented in olp::http::HarCaptureAdapter.
|
virtual |
Sets the current bucket statistics.
| [in] | bucket_id | The bucket ID. |
|
virtual |
Sets the default network headers.
Default headers are applied to each request passed to the Send method. User agents are concatenated.
| headers | The default headers. |