![]() |
Sayonara Player
|
Asynchgronous web access class. More...
#include <AsyncWebAccess.h>
Public Types | |
enum | Behavior : uint8_t { AsBrowser =0, AsSayonara, Random, None } |
The Behavior enum. Responsible for the user-agent variable in the HTTP header. | |
enum | Status : uint8_t { GotData, AudioStream, NoHttp, NoData, Timeout, Error } |
Public Slots | |
void | stop () override |
Signals | |
void | sigFinished () |
Public Member Functions | |
AsyncWebAccess (QObject *parent=nullptr, const QByteArray &header=QByteArray(), AsyncWebAccess::Behavior behavior=AsyncWebAccess::Behavior::AsBrowser) | |
AsyncWebAccess constructor. More... | |
QByteArray | data () const |
get fetched data More... | |
bool | hasData () const |
indicates, if data is avaialbe More... | |
QImage | image () const |
get fetched data formatted as image More... | |
QString | url () const |
get last called url. This url may differ from the originally called url when request has been redirected. More... | |
void | setBehavior (AsyncWebAccess::Behavior behavior) |
Set the behaviour how sayonara should be recognized by the server. This variable will set the user-agent string in the http header. More... | |
void | run (const QString &url, int timeout=4000) |
starts a GET request More... | |
void | runPost (const QString &url, const QByteArray &postData, int timeout=4000) |
starts a POST request More... | |
void | setRawHeader (const QMap< QByteArray, QByteArray > &header) |
modify header. More... | |
AsyncWebAccess::Status | status () const |
Request Status. More... | |
bool | hasError () const |
Indicates if error. More... | |
Asynchgronous web access class.
AsyncWebAccess::AsyncWebAccess | ( | QObject * | parent = nullptr , |
const QByteArray & | header = QByteArray() , |
||
AsyncWebAccess::Behavior | behavior = AsyncWebAccess::Behavior::AsBrowser |
||
) |
AsyncWebAccess constructor.
parent | standard QObject parent |
header | a modified header, see set_raw_header(const QByteArray& header) |
QByteArray AsyncWebAccess::data | ( | ) | const |
get fetched data
bool AsyncWebAccess::hasData | ( | ) | const |
indicates, if data is avaialbe
bool AsyncWebAccess::hasError | ( | ) | const |
Indicates if error.
QImage AsyncWebAccess::image | ( | ) | const |
get fetched data formatted as image
void AsyncWebAccess::run | ( | const QString & | url, |
int | timeout = 4000 |
||
) |
starts a GET request
url | url to call |
timeout | timeout until request is aborted and error is emitted |
void AsyncWebAccess::runPost | ( | const QString & | url, |
const QByteArray & | postData, | ||
int | timeout = 4000 |
||
) |
starts a POST request
url | url to call |
post_data | QByteArray formatted postdata containing ?, = and & characters |
timeout | timeout until request is aborted and error is emitted |
void AsyncWebAccess::setBehavior | ( | AsyncWebAccess::Behavior | behavior | ) |
Set the behaviour how sayonara should be recognized by the server. This variable will set the user-agent string in the http header.
behavior |
void AsyncWebAccess::setRawHeader | ( | const QMap< QByteArray, QByteArray > & | header | ) |
modify header.
header | new header field. e.g. "Content-Type" "text/css" |
AsyncWebAccess::Status AsyncWebAccess::status | ( | ) | const |
Request Status.
QString AsyncWebAccess::url | ( | ) | const |
get last called url.
This url may differ from the originally called url when request has been redirected.