kopete/protocols/messenger/libpapillon
Papillon::HttpTransfer Class Reference
#include <Papillon/Http/Transfer>
Detailed Description
HttpTransfer represent a transfer between a HTTP server.This is wrapper around QHttpHeader and a body. Based on QHttpHeader classes.
Definition at line 38 of file httptransfer.h.
Public Types | |
| enum | HttpTransferType { HttpRequest, HttpResponse } |
Public Member Functions | |
| HttpTransfer (HttpTransferType type=HttpRequest) | |
| ~HttpTransfer () | |
| HttpTransferType | type () const |
| bool | isValid () const |
| uint | contentLength () const |
| QString | contentType () const |
| void | setContentType (const QString &contentType) |
| void | setRequest (const QString &method, const QString &path, int majorVer=1, int minorVer=1) |
| void | setHttpHeader (const QHttpRequestHeader &requestHeader) |
| void | setHttpHeader (const QHttpResponseHeader &responseHeader) |
| bool | hasContentLength () const |
| bool | hasContentType () const |
| bool | hasKey (const QString &key) const |
| QString | value (const QString &key) const |
| QList< QPair< QString, QString > > | values () const |
| void | setValue (const QString &key, const QString &value) |
| void | setValues (const QList< QPair< QString, QString > > &values) |
| int | statusCode () const |
| QString | method () const |
| QString | path () const |
| QByteArray | body () const |
| void | setBody (const QByteArray &body) |
| QByteArray | toRawCommand () |
Member Enumeration Documentation
Determine the Transfer type.
HttpRequest: a HTTP request (with method GET or POST) HttpResponse: a HTTP response (with a status code)
Definition at line 46 of file httptransfer.h.
Constructor & Destructor Documentation
| Papillon::HttpTransfer::HttpTransfer | ( | HttpTransferType | type = HttpRequest |
) |
Build a new HttpTransfer.
By default it is set in HTTP request mode, because this is the kind of HttpTransfer you create manually.
- Parameters:
-
type Type of HttpTransfer, by default HttpRequest.
Definition at line 42 of file httptransfer.cpp.
| Papillon::HttpTransfer::~HttpTransfer | ( | ) |
Member Function Documentation
| HttpTransfer::HttpTransferType Papillon::HttpTransfer::type | ( | ) | const |
Get the current HttpTransfer type.
- Returns:
- the current HttpTransfer type
Definition at line 62 of file httptransfer.cpp.
| bool Papillon::HttpTransfer::isValid | ( | ) | const |
Check if the HttpTransfer is valid.
- Returns:
- true if the HttpTransfer is valid.
Definition at line 67 of file httptransfer.cpp.
| uint Papillon::HttpTransfer::contentLength | ( | ) | const |
Get the Content-Length value.
Use value in the HTTP header.
- Returns:
- the content length.
Definition at line 72 of file httptransfer.cpp.
| QString Papillon::HttpTransfer::contentType | ( | ) | const |
Get the Content-Type for this HTTP transfer.
- Returns:
Definition at line 77 of file httptransfer.cpp.
| void Papillon::HttpTransfer::setContentType | ( | const QString & | contentType | ) |
Set the Content-Type of the HTTP body.
Example are text/html, text/xml, image/png
- Parameters:
-
contentType Content-Type as string.
Definition at line 82 of file httptransfer.cpp.
| void Papillon::HttpTransfer::setRequest | ( | const QString & | method, | |
| const QString & | path, | |||
| int | majorVer = 1, |
|||
| int | minorVer = 1 | |||
| ) |
Set the request details.
Only call this method in HttpRequest method. This is a wrapper around QHttpRequestHeader::setRequest().
- Parameters:
-
method HTTP method, either GET or POST path path to request on server. majorVer HTTP major version (default to 1) minorVer HTTP minir version (default to 1)
Definition at line 87 of file httptransfer.cpp.
| void Papillon::HttpTransfer::setHttpHeader | ( | const QHttpRequestHeader & | requestHeader | ) |
Replace the internal HTTP header with the given HTTP header.
Replace the internal header with the given QHttpRequestHeader.
- Parameters:
-
requestHeader QHttpRequestHeader to replace.
Definition at line 94 of file httptransfer.cpp.
| void Papillon::HttpTransfer::setHttpHeader | ( | const QHttpResponseHeader & | responseHeader | ) |
Replace the internal HTTP header with the given HTTP header.
Same as above, but for QHttpResponseHeader.
- Parameters:
-
responseHeader QHttpResponseHeader to replace.
Definition at line 103 of file httptransfer.cpp.
| bool Papillon::HttpTransfer::hasContentLength | ( | ) | const |
Check if the header contains the "Content-Length" key.
- Returns:
- true if the header contains "Content-Length" key.
Definition at line 112 of file httptransfer.cpp.
| bool Papillon::HttpTransfer::hasContentType | ( | ) | const |
Check if the header contains the "Content-Type" key.
- Returns:
- true if the header contains "Content-Type" key.
Definition at line 117 of file httptransfer.cpp.
| bool Papillon::HttpTransfer::hasKey | ( | const QString & | key | ) | const |
Check if the header has the given key.
- Parameters:
-
key the given key.
- Returns:
- true if the given key was found.
Definition at line 122 of file httptransfer.cpp.
Get the header value for the given key.
- Parameters:
-
key given key.
- Returns:
- the value for the given key.
Definition at line 127 of file httptransfer.cpp.
Get all the key: values.
- Returns:
- all the key: values
Definition at line 132 of file httptransfer.cpp.
Sets the value of the entry with the key to value.
If no entry with key exists, a new entry with the given key and value is created. If an entry with the key already exists, the first value is discarded and replaced with the given value.
- Parameters:
-
key Key value value
Definition at line 137 of file httptransfer.cpp.
Sets the header entries to be the list of key value pairs in values.
- Parameters:
-
values the values.
Definition at line 142 of file httptransfer.cpp.
| int Papillon::HttpTransfer::statusCode | ( | ) | const |
Get the status code from the HTTP Response.
Only available in HttpResponse mode.
- Returns:
- the status code.
Definition at line 147 of file httptransfer.cpp.
| QString Papillon::HttpTransfer::method | ( | ) | const |
Get the HTTP method for the request Use it only in HttpRequest mode.
- Returns:
- the current method
Definition at line 154 of file httptransfer.cpp.
| QString Papillon::HttpTransfer::path | ( | ) | const |
Get the path used in the request.
Use it only in HttpRequest mode.
- Returns:
- the path in the request.
Definition at line 161 of file httptransfer.cpp.
| QByteArray Papillon::HttpTransfer::body | ( | ) | const |
| void Papillon::HttpTransfer::setBody | ( | const QByteArray & | body | ) |
Set the HTTP body Set the Content-Length value according to the body size.
- Parameters:
-
body body to set to the transfer.
Definition at line 173 of file httptransfer.cpp.
| QByteArray Papillon::HttpTransfer::toRawCommand | ( | ) |
Return the current transfer as a raw command.
It formats the HttpTransfer to be ready to be sent on a ByteStream.
Definition at line 179 of file httptransfer.cpp.
The documentation for this class was generated from the following files:
KDE 4.0 API Reference