Skip to content
Permalink
Browse files

working on referer option for http requests

  • Loading branch information
edigonzales committed Mar 27, 2013
1 parent c2dcc72 commit 83d013000597ffc2c8ad6de53cc112dd5962cea3
@@ -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/" )
@@ -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() );

@@ -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();
@@ -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 )
@@ -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" ) );
@@ -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 );
}

@@ -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 );
}
@@ -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;
@@ -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;
}

@@ -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;
@@ -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>

0 comments on commit 83d0130

Please sign in to comment.
You can’t perform that action at this time.