![]() |
Sayonara Player
|
#include <AsyncWebAccess.h>
Asynchgronous web access class.
Public Types | |
enum | Behavior : quint8 { AsBrowser =0, AsSayonara } |
The Behavior enum. Responsible for the user-agent variable in the HTTP header. | |
Signals | |
void | sig_finished (bool success) |
Public Member Functions | |
AsyncWebAccess (QObject *parent=nullptr, const QByteArray &header=QByteArray(), AsyncWebAccess::Behavior behavior=AsyncWebAccess::Behavior::AsBrowser) | |
AsyncWebAccess constructor. More... | |
QByteArray | get_data () const |
get fetched data More... | |
QImage | get_image () const |
get fetched data formatted as image More... | |
QString | get_url () const |
get last called url. This url may differ from the originally called url when request has been redirected. More... | |
void | set_behavior (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 | run_post (const QString &url, const QByteArray &post_data, int timeout=4000) |
starts a POST request More... | |
void | set_raw_header (const QMap< QByteArray, QByteArray > &header) |
modify header. More... | |
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::get_data | ( | ) | const |
get fetched data
QImage AsyncWebAccess::get_image | ( | ) | const |
get fetched data formatted as image
QString AsyncWebAccess::get_url | ( | ) | const |
get last called url.
This url may differ from the originally called url when request has been redirected.
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::run_post | ( | const QString & | url, |
const QByteArray & | post_data, | ||
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::set_behavior | ( | 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::set_raw_header | ( | const QMap< QByteArray, QByteArray > & | header | ) |
modify header.
header | new header field. e.g. "Content-Type" "text/css" |