![]() |
Sayonara Player
|
#include <AsyncWebAccess.h>
Asynchgronous web access class.
Public Types | |
| enum | Behavior : quint8 { AsBrowser =0, AsSayonara, Random, None } |
| The Behavior enum. Responsible for the user-agent variable in the HTTP header. | |
| enum | Status : quint8 { GotData, AudioStream, NoHttp, NoData, Timeout, Error } |
Signals | |
| void | sig_finished () |
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 | has_data () 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 | 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::Status | status () const |
| Request Status. More... | |
| bool | has_error () const |
| Indicates if error. More... | |
| void | stop () override |
| 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::has_data | ( | ) | const |
indicates, if data is avaialbe
| bool AsyncWebAccess::has_error | ( | ) | 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::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" |
| 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.
1.8.13