Skip to content

Commit

Permalink
Add capability of doing HTTP POST request to QgsHttpTransaction. Uses…
Browse files Browse the repository at this point in the history
… a default argument to maintain interface compatibility

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8175 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 23, 2008
1 parent 3eccbb6 commit cd98390
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/core/qgshttptransaction.cpp
Expand Up @@ -67,7 +67,7 @@ void QgsHttpTransaction::getAsynchronously()

}

bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redirections)
bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redirections, const QByteArray* postData)
{

httpredirections = redirections;
Expand Down Expand Up @@ -106,7 +106,16 @@ bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redi
// executing an http GET.
QString pathAndQuery = httpurl.remove(0,
httpurl.indexOf(qurl.path()));
httpid = http->get( pathAndQuery );

if(!postData) //do request with HTTP GET
{
httpid = http->get( pathAndQuery );
}
else //do request with HTTP POST
{
httpid = http->post(pathAndQuery, *postData);
}

connect(http, SIGNAL( requestStarted ( int ) ),
this, SLOT( dataStarted ( int ) ) );

Expand Down
14 changes: 10 additions & 4 deletions src/core/qgshttptransaction.h
Expand Up @@ -64,11 +64,17 @@ class CORE_EXPORT QgsHttpTransaction : public QObject

/*!
The function returns FALSE if there is an error while getting the response.
\param[out] respondedContent is replaced with the new content.
\param[in] redirections is used to measure how many http redirections we've been through.
Clients typically don't need to set this.
@param[out] respondedContent is replaced with the new content.
@param[in] redirections is used to measure how many http redirections we've been through.
Clients typically don't need to set this.
@param postData data to send with the http message. This is only used for HTTP POST. If
0 then the request is done with HTTP GET.
@return true in case of success
*/
bool getSynchronously(QByteArray &respondedContent, int redirections = 0);
bool getSynchronously(QByteArray &respondedContent, int redirections = 0, const QByteArray* postData = 0);

QString responseContentType();

Expand Down

0 comments on commit cd98390

Please sign in to comment.