[QGIS Commit] r9520 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Oct 22 23:54:07 EDT 2008


Author: gsherman
Date: 2008-10-22 23:54:07 -0400 (Wed, 22 Oct 2008)
New Revision: 9520

Modified:
   trunk/qgis/src/core/qgshttptransaction.cpp
Log:
Add user-agent to WMS requests


Modified: trunk/qgis/src/core/qgshttptransaction.cpp
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.cpp	2008-10-22 13:34:08 UTC (rev 9519)
+++ trunk/qgis/src/core/qgshttptransaction.cpp	2008-10-23 03:54:07 UTC (rev 9520)
@@ -23,6 +23,7 @@
 
 #include "qgshttptransaction.h"
 #include "qgslogger.h"
+#include "qgsconfig.h"
 
 #include <QApplication>
 #include <QUrl>
@@ -77,7 +78,15 @@
 
   QUrl qurl( httpurl );
 
-  http = new QHttp( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) );
+  http = new QHttp( ); 
+  // Create a header so we can set the user agent (Per WMS RFC).
+  QHttpRequestHeader header("GET", qurl.host());
+  // Set host in the header
+  header.setValue( "Host", qurl.host() );
+  // Set the user agent to Quantum GIS plus the version name
+  header.setValue( "User-agent", QString("Quantum GIS - ") + VERSION );
+  // Set the host in the QHttp object
+  http->setHost( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) );
 
   if ( httphost.isEmpty() )
   {
@@ -107,13 +116,18 @@
   QString pathAndQuery = httpurl.remove( 0,
                                          httpurl.indexOf( qurl.path() ) );
 
+
   if ( !postData ) //do request with HTTP GET
   {
-    httpid = http->get( pathAndQuery );
+    header.setRequest("GET", pathAndQuery);
+    // do GET using header containing user-agent
+    httpid = http->request(header); 
   }
   else //do request with HTTP POST
   {
-    httpid = http->post( pathAndQuery, *postData );
+    header.setRequest("POST", pathAndQuery);
+    // do POST using header containing user-agent
+    httpid = http->request(header, *postData); 
   }
 
   connect( http, SIGNAL( requestStarted( int ) ),



More information about the QGIS-commit mailing list