|
23 | 23 |
|
24 | 24 | #include "qgshttptransaction.h"
|
25 | 25 | #include "qgslogger.h"
|
| 26 | +#include "qgsconfig.h" |
26 | 27 |
|
27 | 28 | #include <QApplication>
|
28 | 29 | #include <QUrl>
|
@@ -77,7 +78,15 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red
|
77 | 78 |
|
78 | 79 | QUrl qurl( httpurl );
|
79 | 80 |
|
80 |
| - http = new QHttp( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) ); |
| 81 | + http = new QHttp( ); |
| 82 | + // Create a header so we can set the user agent (Per WMS RFC). |
| 83 | + QHttpRequestHeader header("GET", qurl.host()); |
| 84 | + // Set host in the header |
| 85 | + header.setValue( "Host", qurl.host() ); |
| 86 | + // Set the user agent to Quantum GIS plus the version name |
| 87 | + header.setValue( "User-agent", QString("Quantum GIS - ") + VERSION ); |
| 88 | + // Set the host in the QHttp object |
| 89 | + http->setHost( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) ); |
81 | 90 |
|
82 | 91 | if ( httphost.isEmpty() )
|
83 | 92 | {
|
@@ -107,13 +116,18 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red
|
107 | 116 | QString pathAndQuery = httpurl.remove( 0,
|
108 | 117 | httpurl.indexOf( qurl.path() ) );
|
109 | 118 |
|
| 119 | + |
110 | 120 | if ( !postData ) //do request with HTTP GET
|
111 | 121 | {
|
112 |
| - httpid = http->get( pathAndQuery ); |
| 122 | + header.setRequest("GET", pathAndQuery); |
| 123 | + // do GET using header containing user-agent |
| 124 | + httpid = http->request(header); |
113 | 125 | }
|
114 | 126 | else //do request with HTTP POST
|
115 | 127 | {
|
116 |
| - httpid = http->post( pathAndQuery, *postData ); |
| 128 | + header.setRequest("POST", pathAndQuery); |
| 129 | + // do POST using header containing user-agent |
| 130 | + httpid = http->request(header, *postData); |
117 | 131 | }
|
118 | 132 |
|
119 | 133 | connect( http, SIGNAL( requestStarted( int ) ),
|
|
0 commit comments