diff options
author | Valery Kotov <kotov.valery@gmail.com> | 2014-08-18 22:06:38 +0300 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-09-15 10:29:12 +0200 |
commit | 2c54d85bf70e078ab1dfb1465567512aded5cf9d (patch) | |
tree | 39f6d24b70e5784e7619fa7114a9facd80090403 /src/qml/qml/qqmlxmlhttprequest.cpp | |
parent | 404640392b28d253c24330eb8acc0c30d838af92 (diff) |
QML Engine: Support for "OPTIONS" method for XMLHTTPRequest was added.
Support for OPTIONS method was added to QQmlXMLHttpRequest. Tests for
OPTIONS method in XMLHttpRequest were added.
[ChangeLog][QtQml][QQmlXMLHttpRequest] QQmlXMLHttpRequest now
supports the OPTION method in HTTP requests.
Task-number: QTBUG-35892
Change-Id: Ibbcf3ecddeb8ced64d8c3e52b777dd6ec0ed98f7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlxmlhttprequest.cpp')
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index e374e471e3..233dd9c239 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -55,6 +55,7 @@ #include <QtCore/qxmlstream.h> #include <QtCore/qstack.h> #include <QtCore/qdebug.h> +#include <QtCore/qbuffer.h> #include <private/qv4objectproto_p.h> #include <private/qv4scopedvalue_p.h> @@ -1255,16 +1256,23 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url) } } - if (m_method == QLatin1String("GET")) + if (m_method == QLatin1String("GET")) { m_network = networkAccessManager()->get(request); - else if (m_method == QLatin1String("HEAD")) + } else if (m_method == QLatin1String("HEAD")) { m_network = networkAccessManager()->head(request); - else if (m_method == QLatin1String("POST")) + } else if (m_method == QLatin1String("POST")) { m_network = networkAccessManager()->post(request, m_data); - else if (m_method == QLatin1String("PUT")) + } else if (m_method == QLatin1String("PUT")) { m_network = networkAccessManager()->put(request, m_data); - else if (m_method == QLatin1String("DELETE")) + } else if (m_method == QLatin1String("DELETE")) { m_network = networkAccessManager()->deleteResource(request); + } else if (m_method == QLatin1String("OPTIONS")) { + QBuffer *buffer = new QBuffer; + buffer->setData(m_data); + buffer->open(QIODevice::ReadOnly); + m_network = networkAccessManager()->sendCustomRequest(request, QByteArrayLiteral("OPTIONS"), buffer); + buffer->setParent(m_network); + } QObject::connect(m_network, SIGNAL(readyRead()), this, SLOT(readyRead())); @@ -1730,7 +1738,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) method != QLatin1String("PUT") && method != QLatin1String("HEAD") && method != QLatin1String("POST") && - method != QLatin1String("DELETE")) + method != QLatin1String("DELETE") && + method != QLatin1String("OPTIONS")) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type"); // Argument 1 - URL |