Skip to content

Commit

Permalink
working on referer option for http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
edigonzales committed Mar 27, 2013
1 parent c2dcc72 commit 83d0130
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/gui/qgsnewhttpconnection.cpp
Expand Up @@ -58,6 +58,7 @@ QgsNewHttpConnection::QgsNewHttpConnection(

txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
txtReferer->setText( settings.value( credentialsKey + "/referer" ).toString() );
}

if ( mBaseKey != "/Qgis/connections-wms/" )
Expand Down Expand Up @@ -160,6 +161,7 @@ void QgsNewHttpConnection::accept()

settings.setValue( credentialsKey + "/username", txtUserName->text() );
settings.setValue( credentialsKey + "/password", txtPassword->text() );
settings.setValue( credentialsKey + "/referer", txtReferer->text() );

settings.setValue( mBaseKey + "/selected", txtName->text() );

Expand Down
6 changes: 6 additions & 0 deletions src/providers/wms/qgswmsconnection.cpp
Expand Up @@ -67,6 +67,12 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) :
mUri.setParam( "password", password );
}

QString referer = settings.value( credentialsKey + "/referer" ).toString();
if ( !referer.isEmpty() )
{
mUri.setParam( "referer", referer );
}

bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
Expand Down
14 changes: 9 additions & 5 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -97,6 +97,7 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri )
, mErrors( 0 )
, mUserName( QString::null )
, mPassword( QString::null )
, mReferer( QString::null )
, mTiled( false )
, mTileLayer( 0 )
, mTileMatrixSetId( QString::null )
Expand Down Expand Up @@ -161,6 +162,9 @@ bool QgsWmsProvider::parseUri( QString uriString )

mPassword = uri.param( "password" );
QgsDebugMsg( "set password to " + mPassword );

mReferer = uri.param( "referer" );
QgsDebugMsg( "set referer to " + mReferer );

addLayers( uri.params( "layers" ), uri.params( "styles" ) );
setImageEncoding( uri.param( "format" ) );
Expand Down Expand Up @@ -1518,7 +1522,7 @@ int QgsWmsProvider::bandCount() const
void QgsWmsProvider::capabilitiesReplyProgress( qint64 bytesReceived, qint64 bytesTotal )
{
QString msg = tr( "%1 of %2 bytes of capabilities downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) );
QgsDebugMsg( msg );
//QgsDebugMsg( msg );
emit statusChanged( msg );
}

Expand Down Expand Up @@ -2714,13 +2718,13 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )

double res = m.scaleDenom * 0.00028 / metersPerUnit;

QgsDebugMsg( QString( " %1: scale=%2 res=%3 tile=%4x%5 matrix=%6x%7 topLeft=%8" )
/*QgsDebugMsg( QString( " %1: scale=%2 res=%3 tile=%4x%5 matrix=%6x%7 topLeft=%8" )
.arg( m.identifier )
.arg( m.scaleDenom ).arg( res )
.arg( m.tileWidth ).arg( m.tileHeight )
.arg( m.matrixWidth ).arg( m.matrixHeight )
.arg( m.topLeft.toString() )
);
);*/

s.tileMatrices.insert( res, m );
}
Expand All @@ -2738,7 +2742,7 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
e0 = e0.nextSiblingElement( "Layer" ) )
{
QString id = e0.firstChildElement( "ows:Identifier" ).text();
QgsDebugMsg( QString( "Layer %1" ).arg( id ) );
//QgsDebugMsg( QString( "Layer %1" ).arg( id ) );

QgsWmtsTileLayer l;
l.tileMode = WMTS;
Expand Down Expand Up @@ -2936,7 +2940,7 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
}
}

QgsDebugMsg( QString( "add layer %1" ).arg( id ) );
//QgsDebugMsg( QString( "add layer %1" ).arg( id ) );
mTileLayersSupported << l;
}

Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Expand Up @@ -1064,6 +1064,9 @@ class QgsWmsProvider : public QgsRasterDataProvider

//! Password for basic http authentication
QString mPassword;

//! Referer for http requests
QString mReferer;

//! layer is tiled, tile layer and active matrix set
bool mTiled;
Expand Down
10 changes: 10 additions & 0 deletions src/ui/qgsnewhttpconnectionbase.ui
Expand Up @@ -162,6 +162,16 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="txtReferer"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Referer</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 83d0130

Please sign in to comment.