|
22 | 22 |
|
23 | 23 | #include "qgshttptransaction.h" |
24 | 24 | #include "qgslogger.h" |
| 25 | +#include "qgsmessagelog.h" |
25 | 26 | #include "qgsconfig.h" |
26 | 27 |
|
27 | 28 | #include <QApplication> |
|
30 | 31 | #include <QTimer> |
31 | 32 |
|
32 | 33 | static int HTTP_PORT_DEFAULT = 80; |
| 34 | +static int HTTPS_PORT_DEFAULT = 443; |
33 | 35 |
|
34 | 36 | //XXX Set the connection name when creating the provider instance |
35 | 37 | //XXX in qgswmsprovider. When creating a QgsHttpTransaction, pass |
@@ -118,7 +120,14 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red |
118 | 120 | // Set the user agent to QGIS plus the version name |
119 | 121 | header.setValue( "User-agent", QString( "QGIS - " ) + VERSION ); |
120 | 122 | // Set the host in the QHttp object |
121 | | - http->setHost( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) ); |
| 123 | + if ( qurl.scheme() == QString( "https" ) ) |
| 124 | + { |
| 125 | + http->setHost( qurl.host(), QHttp::ConnectionModeHttps, qurl.port( HTTPS_PORT_DEFAULT ) ); |
| 126 | + } |
| 127 | + else |
| 128 | + { |
| 129 | + http->setHost( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) ); |
| 130 | + } |
122 | 131 | // Set the username and password if supplied for this connection |
123 | 132 | // If we have username and password set in header |
124 | 133 | if ( !mUserName.isEmpty() && !mPassword.isEmpty() ) |
@@ -189,6 +198,9 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red |
189 | 198 | connect( http, SIGNAL( stateChanged( int ) ), |
190 | 199 | this, SLOT( dataStateChanged( int ) ) ); |
191 | 200 |
|
| 201 | + connect( http, SIGNAL( sslErrors( const QList<QSslError>& ) ), |
| 202 | + this, SLOT( handleSslErrors( const QList<QSslError>& ) ) ); |
| 203 | + |
192 | 204 | // Set up the watchdog timer |
193 | 205 | connect( mWatchdogTimer, SIGNAL( timeout() ), |
194 | 206 | this, SLOT( networkTimedOut() ) ); |
@@ -485,6 +497,13 @@ void QgsHttpTransaction::dataStateChanged( int state ) |
485 | 497 | } |
486 | 498 | } |
487 | 499 |
|
| 500 | +void QgsHttpTransaction::handleSslErrors( const QList<QSslError> &errors ) |
| 501 | +{ |
| 502 | + Q_FOREACH ( const QSslError &e, errors ) |
| 503 | + { |
| 504 | + QgsMessageLog::logMessage( e.errorString() ); |
| 505 | + } |
| 506 | +} |
488 | 507 |
|
489 | 508 | void QgsHttpTransaction::networkTimedOut() |
490 | 509 | { |
|
0 commit comments