![]() |
TSDuck v3.43-4441
MPEG Transport Stream Toolkit
|
Client request for an InfluxDB server. More...
#include <tsInfluxRequest.h>
Public Member Functions | |
InfluxRequest (Report &report) | |
Constructor. | |
virtual | ~InfluxRequest () override |
Destructor. | |
void | abort () |
Abort a transfer in progress. | |
size_t | announdedContentSize () const |
Get the announced content size in bytes. | |
void | clearPostData () |
Clear previous POST data. | |
void | clearRequestHeaders () |
Clear all headers which will be sent with the request. | |
bool | close () |
Close the transfer. | |
size_t | contentSize () const |
Get the size in bytes of the downloaded content. | |
bool | deleteCookiesFile () const |
Delete the cookies file, if one was defined. | |
void | deleteRequestHeader (const UString &name) |
Delete all headers with a given name. | |
void | disableCookies () |
Disable the use of cookies for all requests. | |
bool | downloadBinaryContent (const UString &url, ByteBlock &data, size_t chunkSize=DEFAULT_CHUNK_SIZE) |
Download the content of the URL as binary data in one operation. | |
bool | downloadFile (const UString &url, const fs::path &fileName, size_t chunkSize=DEFAULT_CHUNK_SIZE) |
Download the content of the URL in a file in one operation. | |
bool | downloadTextContent (const UString &url, UString &text, size_t chunkSize=DEFAULT_CHUNK_SIZE) |
Download the content of the URL as text in one operation. | |
void | enableCompression (bool on=true) |
Enable compression. | |
void | enableCookies (const fs::path &fileName=fs::path()) |
Enable the use of cookies for all requests using this instance. | |
UString | finalURL () const |
Get the final URL of the actual download operation. | |
fs::path | getCookiesFileName () const |
Get the file name to use for cookies for all requests using this instance. | |
void | getResponseHeaders (UStringToUStringMultiMap &headers) const |
Get all response headers. | |
int | httpStatus () const |
Get the HTTP status code (200, 404, etc). | |
int | httpSuccess () const |
Check if the HTTP status code indicates success. | |
bool | isOpen () const |
Check if a transfer is open. | |
UString | mimeType (bool simple=true, bool lowercase=true) const |
Get the MIME type in the response headers. | |
bool | open (const UString &url) |
Open an URL and start the transfer. | |
UString | originalURL () const |
Get the original URL, as set by setURL(). | |
const UString & | proxyHost () const |
Get the current actual proxy host. | |
const UString & | proxyPassword () const |
Get the current actual proxy user password. | |
uint16_t | proxyPort () const |
Get the current actual proxy port number. | |
const UString & | proxyUser () const |
Get the current actual proxy user name. | |
bool | receive (void *buffer, size_t maxSize, size_t &retSize) |
Receive data. | |
UString | reponseHeader (const UString &name) const |
Get the value of one header. | |
Report & | report () |
Use the Report object of this instance. | |
const UStringToUStringMultiMap & | responseHeaders () const |
Get all response headers. | |
void | setArgs (const WebRequestArgs &args) |
Set various arguments from command line. | |
void | setAutoRedirect (bool on) |
Enable or disable the automatic redirection of HTTP requests. | |
void | setConnectionTimeout (cn::milliseconds timeout) |
Set the connection timeout for this request. | |
void | setInsecure (bool on=true) |
Enable or disable HTTPS security (certificate validation). | |
void | setPostData (const ByteBlock &data) |
Set data to POST. | |
void | setPostData (const UString &data, const UString content_type=u"text/plain; charset=utf-8") |
Set data to POST. | |
void | setProxyHost (const UString &host, uint16_t port) |
Set the optional proxy host and port for this request. | |
void | setProxyUser (const UString &user, const UString &password) |
Set the optional proxy authentication for this request. | |
void | setReceiveTimeout (cn::milliseconds timeout) |
Set the timeout for each receive operation. | |
void | setRequestHeader (const UString &name, const UString &value) |
Set a header which will be sent with the request. | |
void | setUserAgent (const UString &name=UString()) |
Set the user agent name to use in HTTP headers. | |
const UString & | userAgent () const |
Get the current user agent name to use in HTTP headers. | |
bool | write (const InfluxArgs &args, const UString &data, const UString &precision) |
Send a write request to the InfluxDB server. | |
Static Public Member Functions | |
static UString | GetLibraryVersion () |
Get the version of the underlying HTTP library. | |
static void | SetDefaultProxyHost (const UString &host, uint16_t port) |
Set the default proxy host and port for all subsequent requests. | |
static void | SetDefaultProxyUser (const UString &user, const UString &password) |
Set the default proxy authentication for all subsequent requests. | |
static UString | ToKey (const UString &name) |
Escape characters in a string to be used as tag key, tag value, or field key. | |
static UString | ToMeasurement (const UString &name) |
Escape characters in a string to be used as measurement. | |
static UString | ToStringValue (const UString &name) |
Escape characters in a string to be used as field value of type string. | |
Static Public Attributes | |
static constexpr size_t | DEFAULT_CHUNK_SIZE = 64 * 1024 |
Default download chunk size for bulk transfers. | |
static constexpr uint16_t | DEFAULT_HTTP_PORT = 80 |
Default TCP port for HTTP. | |
static constexpr uint16_t | DEFAULT_HTTPS_PORT = 443 |
Default TCP port for HTTPS. | |
static constexpr const UChar * | DEFAULT_USER_AGENT = u"tsduck" |
Default user agent string ("tsduck"). | |
Client request for an InfluxDB server.
ts::InfluxRequest::InfluxRequest | ( | Report & | report | ) |
Constructor.
[in,out] | report | Where to report errors. |
bool ts::InfluxRequest::write | ( | const InfluxArgs & | args, |
const UString & | data, | ||
const UString & | precision | ||
) |
Send a write request to the InfluxDB server.
[in] | args | The connection information to the InfluxDB server. |
[in] | data | The data to send, in "line protocol" format. |
[in] | precision | Precision of timestamps. Must be one of "s", "ms", "us", "ns". |
Escape characters in a string to be used as measurement.
[in] | name | The name to transform. |
Escape characters in a string to be used as tag key, tag value, or field key.
[in] | name | The name to transform. |
Escape characters in a string to be used as field value of type string.
Do not use for numerical field values. This function adds surrounding quotes.
[in] | name | The name to transform. |
|
inlineinherited |
|
inlineinherited |
Set the connection timeout for this request.
[in] | timeout | Connection timeout in milliseconds. |
|
inlineinherited |
Set the timeout for each receive operation.
[in] | timeout | Reception timeout in milliseconds. |
|
inherited |
Set the optional proxy host and port for this request.
[in] | host | Proxy host name or address. |
[in] | port | Proxy port number. |
Set the optional proxy authentication for this request.
[in] | user | Proxy user name. |
[in] | password | Proxy user's password. |
|
staticinherited |
Set the default proxy host and port for all subsequent requests.
[in] | host | Proxy host name or address. |
[in] | port | Proxy port number. |
|
staticinherited |
Set the default proxy authentication for all subsequent requests.
[in] | user | Proxy user name. |
[in] | password | Proxy user's password. |
|
inherited |
Get the current actual proxy host.
|
inherited |
Get the current actual proxy port number.
|
inherited |
Get the current actual proxy user name.
|
inherited |
Get the current actual proxy user password.
|
inherited |
Enable the use of cookies for all requests using this instance.
[in] | fileName | The name of the file to use to load and store cookies. On Windows, there is an implicit per-user cookie repository and fileName is ignored. On Unix systems, this file is used to store and retrieve cookies in the libcurl format. When fileName is empty, use a temporary file name. |
|
inherited |
Disable the use of cookies for all requests.
Cookies are initially disabled by default.
|
inherited |
Get the file name to use for cookies for all requests using this instance.
|
inherited |
Delete the cookies file, if one was defined.
Set the user agent name to use in HTTP headers.
[in] | name | The user agent name. If empty, DEFAULT_USER_AGENT is used. |
|
inlineinherited |
Get the current user agent name to use in HTTP headers.
|
inlineinherited |
Enable compression.
Compression is disabled by default.
[in] | on | Boolean setting compression on or off. |
|
inlineinherited |
Enable or disable HTTPS security (certificate validation).
Certificate validation is enabled by default.
[in] | on | If true, disable certificate validation. |
|
inlineinherited |
Enable or disable the automatic redirection of HTTP requests.
This option is active by default.
[in] | on | If true, allow automatic redirection of HTTP requests. |
|
inherited |
Set various arguments from command line.
[in] | args | Command line arguments. |
Set a header which will be sent with the request.
If the same header already exists with another value, a new header is added.
[in] | name | The header name. |
[in] | value | The header value. |
|
inherited |
Delete all headers with a given name.
[in] | name | The header name. |
|
inherited |
Set data to POST.
The request will be a POST one.
[in] | data | Text POST data. The text will be sent in UTF-8 format. |
[in] | content_type | The content type to set in the request headers. The default "Content-Type" header is "text/plain; charset=utf-8", which is usually appropriate. When set to the empty string, no header is set. |
|
inherited |
Set data to POST.
The request will be a POST one.
[in] | data | Binary POST data. |
|
inherited |
Clear previous POST data.
The request will be a GET one.
|
inherited |
|
inlineinherited |
Check if a transfer is open.
|
inlineinherited |
Get the HTTP status code (200, 404, etc).
|
inlineinherited |
Check if the HTTP status code indicates success.
The HTTP status codes are classified as follow (Wikipedia):
|
inlineinherited |
Get the announced content size in bytes.
This is the value which was sent in the content headers. This mat be zero, this may not be the actual size of the content to download.
|
inlineinherited |
Get all response headers.
[out] | headers | A multimap of all response headers. |
|
inlineinherited |
Get all response headers.
Get the value of one header.
[in] | name | Header name, case sensitive. |
|
inherited |
Get the MIME type in the response headers.
[in] | simple | If true, simple type name. If false, return the full specification with options. |
[in] | lowercase | Force lowercase in the result. |
|
inlineinherited |
|
inlineinherited |
Get the final URL of the actual download operation.
It can be different from originalURL() if some HTTP redirections were performed. When called before a download operation, return originalURL().
If redirections are disabled using setAutoRedirect() and the site returned a redirection, finalURL() returns the redirected URL.
|
inherited |
Receive data.
[out] | buffer | Address of the buffer for the received data. |
[in] | maxSize | Size in bytes of the reception buffer. |
[out] | retSize | Size in bytes of the received data. Will never be larger than max_size. When ret_size is zero, this is the end of the transfer. |
|
inherited |
Close the transfer.
|
inherited |
Abort a transfer in progress.
Can be called from another thread.
|
inlineinherited |
Get the size in bytes of the downloaded content.
|
inherited |
|
inherited |
Download the content of the URL as text in one operation.
The open/read/close session is embedded in this method.. The downloaded text is converted from UTF-8. End of lines are normalized as LF.
[in] | url | The complete URL to fetch. |
[out] | text | The content of the URL. |
[in] | chunkSize | Individual download chunk size. |
|
inherited |
Download the content of the URL in a file in one operation.
The open/read/close session is embedded in this method.. No transformation is applied to the data.
[in] | url | The complete URL to fetch. |
[in] | fileName | Name of the file to create. |
[in] | chunkSize | Individual download chunk size. |
|
staticinherited |
Get the version of the underlying HTTP library.