Skip to content

Commit d169bd9

Browse files
author
mhugent
committedFeb 23, 2008
Add capability of doing HTTP POST request to QgsHttpTransaction. Uses a default argument to maintain interface compatibility
git-svn-id: http://svn.osgeo.org/qgis/trunk@8175 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 370a487 commit d169bd9

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed
 

‎src/core/qgshttptransaction.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void QgsHttpTransaction::getAsynchronously()
6767

6868
}
6969

70-
bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redirections)
70+
bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redirections, const QByteArray* postData)
7171
{
7272

7373
httpredirections = redirections;
@@ -106,7 +106,16 @@ bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redi
106106
// executing an http GET.
107107
QString pathAndQuery = httpurl.remove(0,
108108
httpurl.indexOf(qurl.path()));
109-
httpid = http->get( pathAndQuery );
109+
110+
if(!postData) //do request with HTTP GET
111+
{
112+
httpid = http->get( pathAndQuery );
113+
}
114+
else //do request with HTTP POST
115+
{
116+
httpid = http->post(pathAndQuery, *postData);
117+
}
118+
110119
connect(http, SIGNAL( requestStarted ( int ) ),
111120
this, SLOT( dataStarted ( int ) ) );
112121

‎src/core/qgshttptransaction.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ class CORE_EXPORT QgsHttpTransaction : public QObject
6464

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

7379
QString responseContentType();
7480

0 commit comments

Comments
 (0)
Please sign in to comment.