libmygpo-qt
 All Classes Functions
Public Member Functions | List of all members
mygpo::RequestHandler Class Reference

Class for sending HTTP requests and handle the servers response. More...

#include <RequestHandler.h>

Public Member Functions

 RequestHandler (const QString &username, const QString &password, QNetworkAccessManager *nam)
 
 RequestHandler (QNetworkAccessManager *nam)
 
QNetworkReply * getRequest (const QString &url)
 Sends a GET request with the given url and receives the servers response. More...
 
QNetworkReply * authGetRequest (const QString &url)
 Sends a GET request with the given url, adds auth Data to the URL and receives the servers response. More...
 
QNetworkReply * postRequest (const QByteArray data, const QString &url)
 Sends a POST request with the given url and data, adds auth Data and receives the servers response. More...
 

Detailed Description

Class for sending HTTP requests and handle the servers response.

Constructor & Destructor Documentation

mygpo::RequestHandler::RequestHandler ( const QString &  username,
const QString &  password,
QNetworkAccessManager *  nam 
)
Parameters
usernameThe username that should be used for authentication if required.
passwordThe password that should be used for authentication if required

Member Function Documentation

QNetworkReply* mygpo::RequestHandler::authGetRequest ( const QString &  url)

Sends a GET request with the given url, adds auth Data to the URL and receives the servers response.

Parameters
responseThe servers response will be written into this QByteArray
urlThe request url (without http://) as QString
Returns
0 if the request was successful, corresponding ErrorCode if unsuccessful
QNetworkReply* mygpo::RequestHandler::getRequest ( const QString &  url)

Sends a GET request with the given url and receives the servers response.

Parameters
responseThe servers response will be written into this QByteArray
urlThe request url (without http://) as QString
Returns
0 if the request was successful, corresponding ErrorCode if unsuccessful
QNetworkReply* mygpo::RequestHandler::postRequest ( const QByteArray  data,
const QString &  url 
)

Sends a POST request with the given url and data, adds auth Data and receives the servers response.

Parameters
dataThe data to send to the url
urlThe request url (without http://) as QString
Returns
0 if the request was successful, corresponding ErrorCode if unsuccessful

The documentation for this class was generated from the following file: