29 headers.insert(name,QByteArray::number(value));
52 buffer.append(
"HTTP/1.1 ");
56 buffer.append(
"\r\n");
57 foreach(QByteArray name,
headers.keys())
61 buffer.append(
headers.value(name));
62 buffer.append(
"\r\n");
66 buffer.append(
"Set-Cookie: ");
68 buffer.append(
"\r\n");
70 buffer.append(
"\r\n");
77 int remaining=data.size();
78 char* ptr=data.data();
79 while (
socket->isOpen() && remaining>0)
82 if (
socket->bytesToWrite()>16384)
84 socket->waitForBytesWritten(-1);
87 int written=
socket->write(ptr,remaining);
110 headers.insert(
"Content-Length",QByteArray::number(data.size()));
116 QByteArray connectionValue=
headers.value(
"Connection",
headers.value(
"connection"));
117 bool connectionClose=QString::compare(connectionValue,
"close",Qt::CaseInsensitive)==0;
118 if (!connectionClose)
120 headers.insert(
"Transfer-Encoding",
"chunked");
135 QByteArray size=QByteArray::number(data.size(),16);
170 if (!cookie.
getName().isEmpty())
187 write(
"Redirect",
true);
QMap< QByteArray, QByteArray > headers
QByteArray toByteArray() const
QMap< QByteArray, HttpCookie > & getCookies()
void redirect(const QByteArray &url)
void setCookie(const HttpCookie &cookie)
void setHeader(QByteArray name, QByteArray value)
int getStatusCode() const
QMap< QByteArray, QByteArray > & getHeaders()
HttpResponse(QTcpSocket *socket)
QByteArray getName() const
bool hasSentLastPart() const
QMap< QByteArray, HttpCookie > cookies
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
bool writeToSocket(QByteArray data)