Sayonara Player
Public Types | Signals | Public Member Functions | List of all members
AsyncWebAccess Class Reference

#include <AsyncWebAccess.h>

Detailed Description

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...
 

Constructor & Destructor Documentation

AsyncWebAccess::AsyncWebAccess ( QObject *  parent = nullptr,
const QByteArray &  header = QByteArray(),
AsyncWebAccess::Behavior  behavior = AsyncWebAccess::Behavior::AsBrowser 
)

AsyncWebAccess constructor.

Parameters
parentstandard QObject parent
headera modified header, see set_raw_header(const QByteArray& header)

Member Function Documentation

QByteArray AsyncWebAccess::get_data ( ) const

get fetched data

Returns
fetched data
QImage AsyncWebAccess::get_image ( ) const

get fetched data formatted as image

Returns
image
QString AsyncWebAccess::get_url ( ) const

get last called url.
This url may differ from the originally called url when request has been redirected.

Returns
url string
void AsyncWebAccess::run ( const QString &  url,
int  timeout = 4000 
)

starts a GET request

Parameters
urlurl to call
timeouttimeout 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

Parameters
urlurl to call
post_dataQByteArray formatted postdata containing ?, = and & characters
timeouttimeout 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.

Parameters
behavior
void AsyncWebAccess::set_raw_header ( const QMap< QByteArray, QByteArray > &  header)

modify header.

Parameters
headernew header field. e.g. "Content-Type" "text/css"
Inheritance diagram for AsyncWebAccess: