Header Only Library
HTTP Client
How to use HTTP client class
References
#include "IP/InternetProtocol.hpp"
Syntax
Variables
EVerb
FRequest
FResponse
Functions
Set Host
- Set the
adress
andport
of host
Get Socket
- Get socket connection properties
Set Request
- Set the HTTP request to be sent
Get Request
- Get the HTTP request to be sent
Set Request Method
- Set request verb
Get Request Method
- Get request verb
Set Version
- Set request version
Get Version
- Get request version
Set Path
- Set request version
Get Path
- Get request version
Set Params
- Set request parameters
Get Params
- Return a reference of request parameters
- Use this function to modify parameters
Set Headers
- Set request headers
Get Headers
- Return a reference if request headers
- Use this function to modify or append values to headers
Set Body
- Set request body
Get Body
- Return a reference to request body
- Use this function to modify or append value to body
Get Request Data
- Get request data
Prepare Payload
- Prepare request data
- Must be called before call
processRequest
function
Async Prepare Payload
- Prepare request data asynchronously
- Must be called before call
processRequest
function
Get Payload Data
- Get processed payload data
Get Response Data
- Get latest response data
Process Request
- Send request
- Return false if payload is empty
Close
- Close connection or cancel request
Clear Request
- Clear request data
Clear Payload
- Clear payload data
Clear Response
- Clear response buffer
Get Error Code
- Get latest error code
Events
On Async Payload Finished
- Event triggered when payload process has been finished
On Request Progress
- Event triggered while the request is in progress
size_t
: bytes sentsize_t
: bytes received
On Request Complete
- Event triggered when request is done
FResponse
: Response struct
On Request Fail
- Event triggered when request fail
FResponse
: Response struct
On Close
- Event triggered when socket is closed
On Error
- Event triggered if any error occur during async process
const asio::error_code &
: if error occur, error code will be different from 0- Normally, when an error occurs, the socket is automatically closed, triggering the
on_close
event.