Skip to content

Commit

Permalink
Add missing overloads for custom verbs
Browse files Browse the repository at this point in the history
When support for custom verbs was added the overloads for the various
body data options were not.

Task-number: QTBUG-54868
Change-Id: I1a495023d957fc71d1e3b77997a2b4b8531c0a0e
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
richmoore authored and ossilator committed Jul 22, 2016
1 parent bbca3cb commit 4bbcc05
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/network/access/qnetworkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,47 @@ QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &r
return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data));
}

/*!
\since 5.8
\overload
Sends the contents of the \a data byte array to the destination
specified by \a request.
*/
QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, const QByteArray &data)
{
QBuffer *buffer = new QBuffer;
buffer->setData(data);
buffer->open(QIODevice::ReadOnly);

QNetworkReply *reply = sendCustomRequest(request, verb, buffer);
buffer->setParent(reply);
return reply;
}

/*!
\since 5.8
\overload
Sends a custom request to the server identified by the URL of \a request.
Sends the contents of the \a multiPart message to the destination
specified by \a request.
This can be used for sending MIME multipart messages for custom verbs.
\sa QHttpMultiPart, QHttpPart, put()
*/
QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QHttpMultiPart *multiPart)
{
QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart);
QIODevice *device = multiPart->d_func()->device;
QNetworkReply *reply = sendCustomRequest(newRequest, verb, device);
return reply;
}

/*!
Returns a new QNetworkReply object to handle the operation \a op
and request \a req. The device \a outgoingData is always 0 for Get and
Expand Down
2 changes: 2 additions & 0 deletions src/network/access/qnetworkaccessmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
QNetworkReply *put(const QNetworkRequest &request, QHttpMultiPart *multiPart);
QNetworkReply *deleteResource(const QNetworkRequest &request);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = Q_NULLPTR);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, const QByteArray &data);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QHttpMultiPart *multiPart);

#ifndef QT_NO_BEARERMANAGEMENT
void setConfiguration(const QNetworkConfiguration &config);
Expand Down

0 comments on commit 4bbcc05

Please sign in to comment.