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

Asynchgronous web access class. More...

#include <AsyncWebAccess.h>

Inheritance diagram for AsyncWebAccess:
AbstractWebAccess

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

Detailed Description

Asynchgronous web access class.

Constructor & Destructor Documentation

◆ AsyncWebAccess()

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

◆ data()

QByteArray AsyncWebAccess::data ( ) const

get fetched data

Returns
fetched data

◆ hasData()

bool AsyncWebAccess::hasData ( ) const

indicates, if data is avaialbe

Returns

◆ hasError()

bool AsyncWebAccess::hasError ( ) const

Indicates if error.

Returns

◆ image()

QImage AsyncWebAccess::image ( ) const

get fetched data formatted as image

Returns
image

◆ run()

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

◆ runPost()

void AsyncWebAccess::runPost ( const QString &  url,
const QByteArray &  postData,
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

◆ setBehavior()

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.

Parameters
behavior

◆ setRawHeader()

void AsyncWebAccess::setRawHeader ( const QMap< QByteArray, QByteArray > &  header)

modify header.

Parameters
headernew header field. e.g. "Content-Type" "text/css"

◆ status()

AsyncWebAccess::Status AsyncWebAccess::status ( ) const

Request Status.

Returns

◆ url()

QString AsyncWebAccess::url ( ) const

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

Returns
url string