#include <tsWebRequestArgs.h>
Command line arguments for the class WebRequest.
◆ WebRequestArgs()
| ts::WebRequestArgs::WebRequestArgs |
( |
| ) |
|
|
default |
◆ defineArgs()
| void ts::WebRequestArgs::defineArgs |
( |
Args & | args | ) |
|
Add command line option definitions in an Args.
- Parameters
-
| [in,out] | args | Command line arguments to update. |
◆ loadArgs()
| bool ts::WebRequestArgs::loadArgs |
( |
Args & | args | ) |
|
Load arguments from command line. Args error indicator is set in case of incorrect arguments.
- Parameters
-
| [in,out] | args | Command line arguments. |
- Returns
- True on success, false on error in argument line.
◆ setConnectionTimeout()
| void ts::WebRequestArgs::setConnectionTimeout |
( |
cn::milliseconds | timeout | ) |
|
|
inline |
Set the connection timeout for the request (option --connection-timeout).
- Parameters
-
| [in] | timeout | Connection timeout in milliseconds. |
◆ connectionTimeout()
| cn::milliseconds ts::WebRequestArgs::connectionTimeout |
( |
| ) |
const |
|
inline |
Get the connection timeout for the request (option --connection-timeout).
- Returns
- Connection timeout in milliseconds.
◆ setReceiveTimeout()
| void ts::WebRequestArgs::setReceiveTimeout |
( |
cn::milliseconds | timeout | ) |
|
|
inline |
Set the timeout for each receive operation (option --receive-timeout).
- Parameters
-
| [in] | timeout | Reception timeout in milliseconds. |
◆ receiveTimeout()
| cn::milliseconds ts::WebRequestArgs::receiveTimeout |
( |
| ) |
const |
|
inline |
Get the timeout for each receive operation (option --receive-timeout).
- Returns
- Reception timeout in milliseconds.
◆ setProxyHost()
| void ts::WebRequestArgs::setProxyHost |
( |
const UString & | host, |
|
|
uint16_t | port, |
|
|
bool | ignore_empty = false ) |
Set the optional proxy host and port for this request (options --proxy-host and --proxy-port).
- Parameters
-
| [in] | host | Proxy host name or address. |
| [in] | port | Proxy port number. |
| [in] | ignore_empty | If true, empty host name and zero port number are ignored. |
◆ SetDefaultProxyHost()
| void ts::WebRequestArgs::SetDefaultProxyHost |
( |
const UString & | host, |
|
|
uint16_t | port, |
|
|
bool | ignore_empty = false ) |
|
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.
- Parameters
-
| [in] | host | Proxy host name or address. |
| [in] | port | Proxy port number. |
| [in] | ignore_empty | If true, empty host name and zero port number are ignored. |
◆ setProxyUser()
| void ts::WebRequestArgs::setProxyUser |
( |
const UString & | user, |
|
|
const UString & | password, |
|
|
bool | ignore_empty = false ) |
Set the optional proxy authentication for this request (options --proxy-user and --proxy-password).
- Parameters
-
| [in] | user | Proxy user name. |
| [in] | password | Proxy user's password. |
| [in] | ignore_empty | If true, empty user name or password are ignored. |
◆ SetDefaultProxyUser()
| void ts::WebRequestArgs::SetDefaultProxyUser |
( |
const UString & | user, |
|
|
const UString & | password, |
|
|
bool | ignore_empty = false ) |
|
static |
Set the default proxy authentication for all subsequent requests. Initially loaded from environment variables https_proxy or http_proxy.
- Parameters
-
| [in] | user | Proxy user name. |
| [in] | password | Proxy user's password. |
| [in] | ignore_empty | If true, empty user name or password are ignored. |
◆ proxyHost()
| const UString & ts::WebRequestArgs::proxyHost |
( |
| ) |
const |
Get the current actual proxy host (option --proxy-host or default).
- Returns
- A constant reference to the proxy host name.
◆ proxyPort()
| uint16_t ts::WebRequestArgs::proxyPort |
( |
| ) |
const |
Get the current actual proxy port number (option --proxy-port or default).
- Returns
- The proxy port number.
◆ proxyUser()
| const UString & ts::WebRequestArgs::proxyUser |
( |
| ) |
const |
Get the current actual proxy user name (option --proxy-user or default).
- Returns
- A constant reference to the proxy user name.
◆ proxyPassword()
| const UString & ts::WebRequestArgs::proxyPassword |
( |
| ) |
const |
Get the current actual proxy user password (option --proxy-password or default).
- Returns
- A constant reference to the proxy user password.
◆ setMaxDownloadSize()
| void ts::WebRequestArgs::setMaxDownloadSize |
( |
size_t | size | ) |
|
|
inline |
Set a maximum download size. When a download exceeds that size, the transfer is aborted. This limit includes the response headers. The idea is to prevent a hostile server from returnind endless data (or headers). Initially, there is no practical size limit.
- Parameters
-
| [in] | size | Maximum download size in bytes. |
◆ maxDownloadSize()
| size_t ts::WebRequestArgs::maxDownloadSize |
( |
| ) |
const |
|
inline |
Get the maximum download size.
- Returns
- The maximum download size in bytes.
- See also
- setMaxDownloadSize()
◆ enableCookies()
| 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.
- Parameters
-
| [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. |
◆ cookiesEnabled()
| bool ts::WebRequestArgs::cookiesEnabled |
( |
| ) |
const |
|
inline |
Check if cookies are enabled.
- Returns
- True if cookies are enabled, false otherwise.
◆ disableCookies()
| void ts::WebRequestArgs::disableCookies |
( |
| ) |
|
Disable the use of cookies for all requests.
◆ cookiesFileName()
| const fs::path & ts::WebRequestArgs::cookiesFileName |
( |
| ) |
const |
|
inline |
Get the file name to use for cookies for all requests using this instance.
- On Linux, return the current cookie file name, possibly the name of a temporary file if EnableCookies() was called with an empty string.
- On Windows, the cookie repository is defined per user. There is no specific per-application file and this method always report an empty string.
- Returns
- A constant reference to the cookie file name.
◆ deleteTemporaryCookiesFile()
| bool ts::WebRequestArgs::deleteTemporaryCookiesFile |
( |
Report & | report | ) |
const |
Delete the cookies file, if a temporary one was defined.
- Parameters
-
| [in,out] | report | Where to display error messages. |
- Returns
- True on success, false on error.
◆ setUserAgent()
| void ts::WebRequestArgs::setUserAgent |
( |
const UString & | name = UString() | ) |
|
|
inline |
Set the user agent name to use in HTTP headers (option --user-agent).
- Parameters
-
| [in] | name | The user agent name. If empty, DEFAULT_USER_AGENT is used. |
◆ userAgent()
| const UString & ts::WebRequestArgs::userAgent |
( |
| ) |
const |
|
inline |
Get the current user agent name to use in HTTP headers (option --user-agent).
- Returns
- A constant reference to the user agent name to use in HTTP headers.
◆ enableCompression()
| void ts::WebRequestArgs::enableCompression |
( |
bool | on | ) |
|
|
inline |
Enable compression (optoin --compressed). Compression is disabled by default.
- Parameters
-
| [in] | on | Boolean setting compression on or off. |
◆ compressionEnabled()
| bool ts::WebRequestArgs::compressionEnabled |
( |
| ) |
const |
|
inline |
Check if compression is enabled.
- Returns
- True if compression is enabled.
◆ setInsecure()
| void ts::WebRequestArgs::setInsecure |
( |
bool | on | ) |
|
|
inline |
Enable or disable HTTPS security (certificate validation). Certificate validation is enabled by default.
- Parameters
-
| [in] | on | If true, disable certificate validation. |
◆ isInsecure()
| bool ts::WebRequestArgs::isInsecure |
( |
| ) |
const |
|
inline |
Check if HTTPS security is disabled.
- Returns
- True if HTTPS security is disabled.
◆ setAutoRedirect()
| void ts::WebRequestArgs::setAutoRedirect |
( |
bool | on | ) |
|
|
inline |
Enable or disable the automatic redirection of HTTP requests. Automatic redirection is enabled by default.
- Parameters
-
| [in] | on | If true, allow automatic redirection of HTTP requests. |
◆ autoRedirect()
| bool ts::WebRequestArgs::autoRedirect |
( |
| ) |
const |
|
inline |
Check if automatic redirection of HTTP requests is enabled.
- Returns
- True if automatic redirection of HTTP requests is enabled.
◆ setRequestHeader()
| void ts::WebRequestArgs::setRequestHeader |
( |
const UString & | name, |
|
|
const UString & | value ) |
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.
- Parameters
-
| [in] | name | The header name. |
| [in] | value | The header value. |
◆ deleteRequestHeader()
| void ts::WebRequestArgs::deleteRequestHeader |
( |
const UString & | name | ) |
|
|
inline |
Delete all request headers with a given name.
- Parameters
-
◆ clearRequestHeaders()
| void ts::WebRequestArgs::clearRequestHeaders |
( |
| ) |
|
|
inline |
Clear all headers which will be sent with the request.
◆ requestHeaders()
Get all request headers.
- Returns
- A constant reference to a map of request headers.
◆ appendRequestHeaders()
| void ts::WebRequestArgs::appendRequestHeaders |
( |
UString & | text | ) |
const |
Append all request headers to a text string. Header lines are separated by CR-LF.
- Parameters
-
| [in,out] | text | Where to append the text lines. |
◆ setPostData() [1/2]
| 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.
- Parameters
-
| [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. |
◆ setPostData() [2/2]
| void ts::WebRequestArgs::setPostData |
( |
const ByteBlock & | data | ) |
|
|
inline |
Set data to POST. The request will be a POST one.
- Parameters
-
| [in] | data | Binary POST data. |
◆ clearPostData()
| void ts::WebRequestArgs::clearPostData |
( |
| ) |
|
|
inline |
Clear previous POST data. The request will be a GET one.
◆ isPost()
| bool ts::WebRequestArgs::isPost |
( |
| ) |
const |
|
inline |
Check if the request is a POST one.
- Returns
- True if the request is a POST one.
◆ postData()
| const ByteBlock & ts::WebRequestArgs::postData |
( |
| ) |
const |
|
inline |
Get the POST data.
- Returns
- A constant reference to the binary POST data.
◆ requestName()
| UString ts::WebRequestArgs::requestName |
( |
| ) |
const |
|
inline |
Get the HTTP request name.
- Returns
- "GET" or "POST".
◆ DEFAULT_HTTP_PORT
| uint16_t ts::WebRequestArgs::DEFAULT_HTTP_PORT = 80 |
|
staticconstexpr |
Default TCP port for HTTP.
◆ DEFAULT_HTTPS_PORT
| uint16_t ts::WebRequestArgs::DEFAULT_HTTPS_PORT = 443 |
|
staticconstexpr |
Default TCP port for HTTPS.
◆ DEFAULT_USER_AGENT
| const UChar* ts::WebRequestArgs::DEFAULT_USER_AGENT = u"tsduck" |
|
staticconstexpr |
Default user agent string ("tsduck").
The documentation for this class was generated from the following file: