source: trunk/src/network/access/qhttpnetworkreply.cpp@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 25.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtNetwork module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qhttpnetworkreply_p.h"
43#include "qhttpnetworkconnection_p.h"
44
45#include <qbytearraymatcher.h>
46
47#ifndef QT_NO_HTTP
48
49#ifndef QT_NO_OPENSSL
50# include <QtNetwork/qsslkey.h>
51# include <QtNetwork/qsslcipher.h>
52# include <QtNetwork/qsslconfiguration.h>
53#endif
54
55QT_BEGIN_NAMESPACE
56
57QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent)
58 : QObject(*new QHttpNetworkReplyPrivate(url), parent)
59{
60}
61
62QHttpNetworkReply::~QHttpNetworkReply()
63{
64 Q_D(QHttpNetworkReply);
65 if (d->connection) {
66 d->connection->d_func()->removeReply(this);
67 }
68}
69
70QUrl QHttpNetworkReply::url() const
71{
72 return d_func()->url;
73}
74void QHttpNetworkReply::setUrl(const QUrl &url)
75{
76 Q_D(QHttpNetworkReply);
77 d->url = url;
78}
79
80qint64 QHttpNetworkReply::contentLength() const
81{
82 return d_func()->contentLength();
83}
84
85void QHttpNetworkReply::setContentLength(qint64 length)
86{
87 Q_D(QHttpNetworkReply);
88 d->setContentLength(length);
89}
90
91QList<QPair<QByteArray, QByteArray> > QHttpNetworkReply::header() const
92{
93 return d_func()->fields;
94}
95
96QByteArray QHttpNetworkReply::headerField(const QByteArray &name, const QByteArray &defaultValue) const
97{
98 return d_func()->headerField(name, defaultValue);
99}
100
101void QHttpNetworkReply::setHeaderField(const QByteArray &name, const QByteArray &data)
102{
103 Q_D(QHttpNetworkReply);
104 d->setHeaderField(name, data);
105}
106
107void QHttpNetworkReply::parseHeader(const QByteArray &header)
108{
109 Q_D(QHttpNetworkReply);
110 d->parseHeader(header);
111}
112
113QHttpNetworkRequest QHttpNetworkReply::request() const
114{
115 return d_func()->request;
116}
117
118void QHttpNetworkReply::setRequest(const QHttpNetworkRequest &request)
119{
120 Q_D(QHttpNetworkReply);
121 d->request = request;
122}
123
124int QHttpNetworkReply::statusCode() const
125{
126 return d_func()->statusCode;
127}
128
129void QHttpNetworkReply::setStatusCode(int code)
130{
131 Q_D(QHttpNetworkReply);
132 d->statusCode = code;
133}
134
135QString QHttpNetworkReply::errorString() const
136{
137 return d_func()->errorString;
138}
139
140QString QHttpNetworkReply::reasonPhrase() const
141{
142 return d_func()->reasonPhrase;
143}
144
145void QHttpNetworkReply::setErrorString(const QString &error)
146{
147 Q_D(QHttpNetworkReply);
148 d->errorString = error;
149}
150
151int QHttpNetworkReply::majorVersion() const
152{
153 return d_func()->majorVersion;
154}
155
156int QHttpNetworkReply::minorVersion() const
157{
158 return d_func()->minorVersion;
159}
160
161qint64 QHttpNetworkReply::bytesAvailable() const
162{
163 Q_D(const QHttpNetworkReply);
164 if (d->connection)
165 return d->connection->d_func()->uncompressedBytesAvailable(*this);
166 else
167 return -1;
168}
169
170qint64 QHttpNetworkReply::bytesAvailableNextBlock() const
171{
172 Q_D(const QHttpNetworkReply);
173 if (d->connection)
174 return d->connection->d_func()->uncompressedBytesAvailableNextBlock(*this);
175 else
176 return -1;
177}
178
179QByteArray QHttpNetworkReply::readAny()
180{