nx_camera_sdk  1.0
Camera SDK
Public Member Functions | Static Public Attributes | List of all members
SyncHttpClient Class Reference

Synchronous wrapper on top of QNetworkAccessManager. More...

#include <sync_http_client.h>

Public Member Functions

 SyncHttpClient (QNetworkAccessManager *networkAccessManager, const QUrl &defaultUrl=QUrl(), int defaultPort=0, const QAuthenticator &defaultCredentials=QAuthenticator())
 
 SyncHttpClient (QNetworkAccessManager *networkAccessManager, const QString &defaultUrlStr, int defaultPort=0, const QAuthenticator &defaultCredentials=QAuthenticator())
 
QNetworkReply::NetworkError get (const QNetworkRequest &request)
 Perform GET request. More...
 
QNetworkReply::NetworkError get (const QUrl &requestUrl)
 Same as another get.
 
QNetworkReply::NetworkError get (const QString &requestUrl)
 Same as another get.
 
QByteArray readWholeMessageBody ()
 Reads whole message body. May block.
 
int statusCode () const
 Holds http status code of prev request. Undefined, if get returned code different from QNetworkReply::NoError.
 

Static Public Attributes

static const int HTTP_OK = 200
 
static const int HTTP_BAD_REQUEST = 400
 
static const int HTTP_NOT_AUTHORIZED = 401
 

Detailed Description

Synchronous wrapper on top of QNetworkAccessManager.

Host and port can be specified at object construction, than get can accept only http path

Note
This class instance is not thread-safe but can be used in any thread except QNetworkAccessManager thread (in contrast with QNetworkAccessManager which can be used in its thread only)

Constructor & Destructor Documentation

◆ SyncHttpClient()

SyncHttpClient::SyncHttpClient ( QNetworkAccessManager *  networkAccessManager,
const QUrl &  defaultUrl = QUrl(),
int  defaultPort = 0,
const QAuthenticator &  defaultCredentials = QAuthenticator() 
)
Parameters
networkAccessManagerThis object MUST not be freed earlier, than SyncHttpClient object
defaultUrlContains host and port to use if url passed to get does not contain host & port
defaultPortUsed as default if defaultUrl does not contain port
defaultCredentialsUsed as default if defaultUrl does not contain user credentials

Member Function Documentation

◆ get()

QNetworkReply::NetworkError SyncHttpClient::get ( const QNetworkRequest &  request)

Perform GET request.

Blocks till valid response has been recevied or an error occured

Parameters
request
Returns
In case of valid response received, returns QNetworkReply::NoError (but *httpStatusCode may contain some http error)

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