summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-06-07 00:24:47 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-07 23:14:16 +0200
commit908de0fb8d86945b7583b01f8d17c6e0afa6a864 (patch)
tree6b59e358b60495fbb8f5747f161b02880af31151 /src/network
parent398ae00e84433789598a716cd3e6202a2f76f1fd (diff)
NSURLConnection: Set http response status code.
Make XMLHttpRequest.status work. Task-number: QTBUG-38864 Change-Id: Ic691b39a43aeb2ad3cd2e8ffef64c74d02699755 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkreplynsurlconnectionimpl.mm13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/network/access/qnetworkreplynsurlconnectionimpl.mm b/src/network/access/qnetworkreplynsurlconnectionimpl.mm
index d49324918e..f93f18357a 100644
--- a/src/network/access/qnetworkreplynsurlconnectionimpl.mm
+++ b/src/network/access/qnetworkreplynsurlconnectionimpl.mm
@@ -90,6 +90,7 @@ public:
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
void setRawHeader(const QByteArray &headerName, const QByteArray &value);
void setError(QNetworkReply::NetworkError errorCode, const QString &errorString);
+ void setAttribute(QNetworkRequest::Attribute code, const QVariant &value);
};
@interface QtNSURLConnectionDelegate : NSObject
@@ -140,6 +141,7 @@ QNetworkReplyNSURLConnectionImplPrivate::~QNetworkReplyNSURLConnectionImplPrivat
void QNetworkReplyNSURLConnectionImplPrivate::setFinished()
{
q_func()->setFinished(true);
+ QMetaObject::invokeMethod(q_func(), "finished", Qt::QueuedConnection);
}
void QNetworkReplyNSURLConnectionImplPrivate::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
@@ -157,6 +159,11 @@ void QNetworkReplyNSURLConnectionImplPrivate::setError(QNetworkReply::NetworkErr
q_func()->setError(errorCode, errorString);
}
+void QNetworkReplyNSURLConnectionImplPrivate::setAttribute(QNetworkRequest::Attribute code, const QVariant &value)
+{
+ q_func()->setAttribute(code, value);
+}
+
void QNetworkReplyNSURLConnectionImpl::readyReadOutgoingData()
{
Q_D(QNetworkReplyNSURLConnectionImpl);
@@ -269,6 +276,9 @@ void QNetworkReplyNSURLConnectionImpl::readyReadOutgoingData()
NSString *value = [headers objectForKey:key];
replyprivate->setRawHeader(QString::fromNSString(key).toUtf8(), QString::fromNSString(value).toUtf8());
}
+
+ int code = [httpResponse statusCode];
+ replyprivate->setAttribute(QNetworkRequest::HttpStatusCodeAttribute, code);
} else {
if ([aResponse expectedContentLength] != NSURLResponseUnknownLength)
replyprivate->setHeader(QNetworkRequest::ContentLengthHeader, [aResponse expectedContentLength]);
@@ -317,8 +327,7 @@ void QNetworkReplyNSURLConnectionImpl::readyReadOutgoingData()
- (void)connectionDidFinishLoading:(NSURLConnection*)connection
{
Q_UNUSED(connection)
- replyprivate->setFinished();
- QMetaObject::invokeMethod(replyprivate->q_func(), "finished", Qt::QueuedConnection);
+ replyprivate->setFinished();
}
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection*)connection