![]() |
TSDuck v3.45-4796
MPEG Transport Stream Toolkit
|
Command line arguments for the class WebRequest. More...
#include <tsWebRequestArgs.h>
Public Member Functions | |
| WebRequestArgs ()=default | |
| Constructor. | |
| void | appendRequestHeaders (UString &text) const |
| Append all request headers to a text string. | |
| bool | autoRedirect () const |
| Check if automatic redirection of HTTP requests is enabled. | |
| void | clearPostData () |
| Clear previous POST data. | |
| void | clearRequestHeaders () |
| Clear all headers which will be sent with the request. | |
| bool | compressionEnabled () const |
| Check if compression is enabled. | |
| cn::milliseconds | connectionTimeout () const |
| Get the connection timeout for the request (option --connection-timeout). | |
| bool | cookiesEnabled () const |
| Check if cookies are enabled. | |
| const fs::path & | cookiesFileName () const |
| Get the file name to use for cookies for all requests using this instance. | |
| void | defineArgs (Args &args) |
| Add command line option definitions in an Args. | |
| void | deleteRequestHeader (const UString &name) |
| Delete all request headers with a given name. | |
| bool | deleteTemporaryCookiesFile (Report &report) const |
| Delete the cookies file, if a temporary one was defined. | |
| void | disableCookies () |
| Disable the use of cookies for all requests. | |
| void | enableCompression (bool on) |
| Enable compression (optoin --compressed). | |
| void | enableCookies (const fs::path &file_name=fs::path()) |
| Enable the propagation of cookies for all requests using the same instance of a web request. | |
| bool | isInsecure () const |
| Check if HTTPS security is disabled. | |
| bool | isPost () const |
| Check if the request is a POST one. | |
| bool | loadArgs (Args &args) |
| Load arguments from command line. | |
| const ByteBlock & | postData () const |
| Get the POST data. | |
| const UString & | proxyHost () const |
| Get the current actual proxy host (option --proxy-host or default). | |
| const UString & | proxyPassword () const |
| Get the current actual proxy user password (option --proxy-password or default). | |
| uint16_t | proxyPort () const |
| Get the current actual proxy port number (option --proxy-port or default). | |
| const UString & | proxyUser () const |
| Get the current actual proxy user name (option --proxy-user or default). | |
| cn::milliseconds | receiveTimeout () const |
| Get the timeout for each receive operation (option --receive-timeout). | |
| const UStringToUStringMultiMap & | requestHeaders () const |
| Get all request headers. | |
| UString | requestName () const |
| Get the HTTP request name. | |
| void | setAutoRedirect (bool on) |
| Enable or disable the automatic redirection of HTTP requests. | |
| void | setConnectionTimeout (cn::milliseconds timeout) |
| Set the connection timeout for the request (option --connection-timeout). | |
| void | setInsecure (bool on) |
| 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 (options --proxy-host and --proxy-port). | |
| void | setProxyUser (const UString &user, const UString &password) |
| Set the optional proxy authentication for this request (options --proxy-user and --proxy-password). | |
| void | setReceiveTimeout (cn::milliseconds timeout) |
| Set the timeout for each receive operation (option --receive-timeout). | |
| void | setRequestHeader (const UString &name, const UString &value) |
| Set a header which will be sent with the request (option --headers). | |
| void | setUserAgent (const UString &name=UString()) |
| Set the user agent name to use in HTTP headers (option --user-agent). | |
| const UString & | userAgent () const |
| Get the current user agent name to use in HTTP headers (option --user-agent). | |
Static Public Member Functions | |
| static void | SetDefaultProxyHost (const UString &host, uint16_t port) |
| Set the default proxy host and port for all subsequent Web requests in the application. | |
| static void | SetDefaultProxyUser (const UString &user, const UString &password) |
| Set the default proxy authentication for all subsequent requests. | |
Static Public Attributes | |
| 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"). | |
Command line arguments for the class WebRequest.
| void ts::WebRequestArgs::defineArgs | ( | Args & | args | ) |
Add command line option definitions in an Args.
| [in,out] | args | Command line arguments to update. |
| bool ts::WebRequestArgs::loadArgs | ( | Args & | args | ) |
Load arguments from command line.
Args error indicator is set in case of incorrect arguments.
| [in,out] | args | Command line arguments. |
|
inline |
Set the connection timeout for the request (option --connection-timeout).
| [in] | timeout | Connection timeout in milliseconds. |
|
inline |
Get the connection timeout for the request (option --connection-timeout).
|
inline |
Set the timeout for each receive operation (option --receive-timeout).
| [in] | timeout | Reception timeout in milliseconds. |
|
inline |
Get the timeout for each receive operation (option --receive-timeout).
| void ts::WebRequestArgs::setProxyHost | ( | const UString & | host, |
| uint16_t | port | ||
| ) |
Set the optional proxy host and port for this request (options --proxy-host and --proxy-port).
| [in] | host | Proxy host name or address. |
| [in] | port | Proxy port number. |
|
static |
Set the default proxy host and port for all subsequent Web requests in the application.
Initially loaded from environment variables https_proxy or http_proxy.
| [in] | host | Proxy host name or address. |
| [in] | port | Proxy port number. |
Set the optional proxy authentication for this request (options --proxy-user and --proxy-password).
| [in] | user | Proxy user name. |
| [in] | password | Proxy user's password. |
|
static |
Set the default proxy authentication for all subsequent requests.
Initially loaded from environment variables https_proxy or http_proxy.
| [in] | user | Proxy user name. |
| [in] | password | Proxy user's password. |
| const UString & ts::WebRequestArgs::proxyHost | ( | ) | const |
Get the current actual proxy host (option --proxy-host or default).
| uint16_t ts::WebRequestArgs::proxyPort | ( | ) | const |
Get the current actual proxy port number (option --proxy-port or default).
| const UString & ts::WebRequestArgs::proxyUser | ( | ) | const |
Get the current actual proxy user name (option --proxy-user or default).
| const UString & ts::WebRequestArgs::proxyPassword | ( | ) | const |
Get the current actual proxy user password (option --proxy-password or default).
| void ts::WebRequestArgs::enableCookies | ( | const fs::path & | file_name = fs::path() | ) |
Enable the propagation of cookies for all requests using the same instance of a web request.
Cookies are initially enabled by default.
| [in] | file_name | 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. |
|
inline |
Check if cookies are enabled.
|
inline |
Get the file name to use for cookies for all requests using this instance.
| bool ts::WebRequestArgs::deleteTemporaryCookiesFile | ( | Report & | report | ) | const |
Delete the cookies file, if a temporary one was defined.
| [in,out] | report | Where to display error messages. |
Set the user agent name to use in HTTP headers (option --user-agent).
| [in] | name | The user agent name. If empty, DEFAULT_USER_AGENT is used. |
|
inline |
Get the current user agent name to use in HTTP headers (option --user-agent).
|
inline |
Enable compression (optoin --compressed).
Compression is disabled by default.
| [in] | on | Boolean setting compression on or off. |
|
inline |
Check if compression is enabled.
|
inline |
Enable or disable HTTPS security (certificate validation).
Certificate validation is enabled by default.
| [in] | on | If true, disable certificate validation. |
|
inline |
Check if HTTPS security is disabled.
|
inline |
Enable or disable the automatic redirection of HTTP requests.
Automatic redirection is enabled by default.
| [in] | on | If true, allow automatic redirection of HTTP requests. |
|
inline |
Check if automatic redirection of HTTP requests is enabled.
Set a header which will be sent with the request (option --headers).
If the same header already exists with another value, a new header is added.
| [in] | name | The header name. |
| [in] | value | The header value. |
|
inline |
Delete all request headers with a given name.
| [in] | name | The header name. |
|
inline |
Get all request headers.
| void ts::WebRequestArgs::appendRequestHeaders | ( | UString & | text | ) | const |
Append all request headers to a text string.
Header lines are separated by CR-LF.
| [in,out] | text | Where to append the text lines. |
| void ts::WebRequestArgs::setPostData | ( | const UString & | data, |
| const UString | content_type = u"text/plain; charset=utf-8" |
||
| ) |
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. |
|
inline |
Set data to POST.
The request will be a POST one.
| [in] | data | Binary POST data. |
|
inline |
Clear previous POST data.
The request will be a GET one.
|
inline |
Check if the request is a POST one.
|
inline |
Get the POST data.
|
inline |
Get the HTTP request name.