Status of a WebRequest.
More...
#include <tsWebRequestStatus.h>
◆ WebRequestStatus()
| ts::WebRequestStatus::WebRequestStatus |
( |
const UString & |
url = UString() | ) |
|
Constructor.
- Parameters
-
| [in] | url | Optional original URL of the request. |
◆ reset()
Reset the WebRequest status.
This method is typically used before starting a new request.
- Parameters
-
| [in] | url | Optional original URL of the request. |
◆ originalURL()
| const UString & ts::WebRequestStatus::originalURL |
( |
| ) |
const |
|
inline |
Get the original URL, as set by the constructor or reset().
- Returns
- A constant reference to the original URL.
◆ finalURL()
| const UString & ts::WebRequestStatus::finalURL |
( |
| ) |
const |
|
inline |
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 WebRequestArgs::setAutoRedirect() and the site returned a redirection, finalURL() returns the redirected URL.
- Returns
- A constant reference to the final / redirected URL.
◆ setFinalURL()
| void ts::WebRequestStatus::setFinalURL |
( |
const UString & |
url, |
|
|
bool |
only_if_different = false |
|
) |
| |
Set the final URL of the actual download operation.
- Parameters
-
| [in] | url | The final URL. |
| [in] | only_if_different | If true, do not set the final URL if url is the same value as the original URL. If false (the default), the final URL is unconditionally set with the value of url. |
◆ processReponseHeaders()
| void ts::WebRequestStatus::processReponseHeaders |
( |
const UString & |
text, |
|
|
Report & |
report |
|
) |
| |
Process a list of response headers.
Set response headers and HTTP status when present. When header "Location" is found, set the final URL to the specified redirection. When header "Content-length" is found, set the announced content size.
- Parameters
-
| [in] | text | Multi-line HTTP response text. If it starts from the beginning of the session response (initial "HTTP/" header), the HTTP status is extracted. Header lines are terminated by LF or CR-LF. |
| [in,out] | report | Where to report debug messages. |
◆ httpStatus()
| int ts::WebRequestStatus::httpStatus |
( |
| ) |
const |
|
inline |
Get the HTTP status code (200, 404, etc).
- Returns
- The HTTP status code.
◆ setHttpStatus()
| void ts::WebRequestStatus::setHttpStatus |
( |
int |
status | ) |
|
|
inline |
◆ httpSuccess()
| bool ts::WebRequestStatus::httpSuccess |
( |
| ) |
const |
|
inline |
Check if the HTTP status code indicates success.
The HTTP status codes are classified as follow (Wikipedia):
- 1xx informational response – the request was received, continuing process
- 2xx successful – the request was successfully received, understood, and accepted
- 3xx redirection – further action needs to be taken in order to complete the request
- 4xx client error – the request contains bad syntax or cannot be fulfilled
- 5xx server error – the server failed to fulfil an apparently valid request
- Returns
- True if the HTTP status code indicates success.
◆ httpRedirection()
| bool ts::WebRequestStatus::httpRedirection |
( |
| ) |
const |
|
inline |
Check if the HTTP status code indicates a redirection.
Redirection codes are 3xx (eg. "HTTP/1.1 301 Moved Permanently").
- Returns
- True if the HTTP status code indicates a redirection.
◆ httpClientError()
| bool ts::WebRequestStatus::httpClientError |
( |
| ) |
const |
|
inline |
Check if the HTTP status code indicates a client error.
- Returns
- True if the HTTP status code indicates a client error.
◆ httpServerError()
| bool ts::WebRequestStatus::httpServerError |
( |
| ) |
const |
|
inline |
Check if the HTTP status code indicates a server error.
- Returns
- True if the HTTP status code indicates a server error.
◆ announcedContentSize()
| size_t ts::WebRequestStatus::announcedContentSize |
( |
| ) |
const |
|
inline |
Get the announced content size in bytes.
This is the value which was sent in the response headers. This may be zero, this may not be the actual size of the content to download.
- Returns
- Announced content size in bytes.
◆ contentSize()
| size_t ts::WebRequestStatus::contentSize |
( |
| ) |
const |
|
inline |
Get the size in bytes of the downloaded content.
It must be set by the application when the actual content was downloaded.
- Returns
- Size in bytes of the downloaded content.
◆ setContentSize()
| void ts::WebRequestStatus::setContentSize |
( |
size_t |
size | ) |
|
|
inline |
Set the size in bytes of the downloaded content.
- Parameters
-
| [in] | size | Size in bytes of the downloaded content. |
◆ addContentSize()
| void ts::WebRequestStatus::addContentSize |
( |
size_t |
size | ) |
|
|
inline |
Add a value to the size in bytes of the downloaded content.
Can be called each time a chunk of downloaded data is received.
- Parameters
-
| [in] | size | Size in bytes of the additional downloaded content. |
◆ responseHeaders()
Get all response headers.
- Returns
- A constant reference to a map of response headers.
◆ reponseHeader()
| UString ts::WebRequestStatus::reponseHeader |
( |
const UString & |
name | ) |
const |
Get the value of one response header.
- Parameters
-
| [in] | name | Header name, not case sensitive. |
- Returns
- Header value or an empty string when the header is not found. If the header is present more than once, the first value is returned.
◆ mimeType()
| UString ts::WebRequestStatus::mimeType |
( |
bool |
simple = true, |
|
|
bool |
lowercase = true |
|
) |
| const |
Get the MIME type in the response headers.
- Parameters
-
| [in] | simple | If true, simple type name. If false, return the full specification with options. |
| [in] | lowercase | Force lowercase in the result. |
- Returns
- The MIME type.
The documentation for this class was generated from the following file: