Skip to content
Permalink
Browse files

referer for wfs: one has to modify a lot... stop here and consider on…

…ly wms
  • Loading branch information
Stefan Ziegler
Stefan Ziegler committed Mar 29, 2013
1 parent b06eeca commit ade381f02e29a65b305b15da6d3128edd7805289
@@ -93,6 +93,12 @@ QgsOWSConnection::QgsOWSConnection( const QString & theService, const QString &
mUri.setParam( "password", password );
}

QString referer = settings.value( key + "/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();
@@ -347,6 +347,8 @@ QDomDocument QgsManageConnectionsDialog::saveOWSConnections( const QStringList &
el.setAttribute( "invertAxisOrientation", settings.value( path + connections[i] + "/invertAxisOrientation", false ).toBool() ? "true" : "false" );
}

el.setAttribute( "referer", settings.value( path + connections[ i ] + "/referer", "" ).toString() );

path = "/Qgis/" + service.toUpper() + "/";
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
el.setAttribute( "password", settings.value( path + connections[ i ] + "/password", "" ).toString() );
@@ -372,6 +374,8 @@ QDomDocument QgsManageConnectionsDialog::saveWFSConnections( const QStringList &
el.setAttribute( "name", connections[ i ] );
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() );

el.setAttribute( "referer", settings.value( path + connections[ i ] + "/referer", "" ).toString() );

path = "/Qgis/WFS/";
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
el.setAttribute( "password", settings.value( path + connections[ i ] + "/password", "" ).toString() );
@@ -576,6 +580,7 @@ void QgsManageConnectionsDialog::loadOWSConnections( const QDomDocument &doc, co
settings.setValue( QString( "/" + connectionName + "/ignoreGetFeatureInfoURI" ), child.attribute( "ignoreGetFeatureInfoURI" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/ignoreAxisOrientation" ), child.attribute( "ignoreAxisOrientation" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/invertAxisOrientation" ), child.attribute( "invertAxisOrientation" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/referer" ), child.attribute( "referer" ) );
settings.endGroup();

if ( !child.attribute( "username" ).isEmpty() )
@@ -656,6 +661,7 @@ void QgsManageConnectionsDialog::loadWFSConnections( const QDomDocument &doc, co
// no dups detected or overwrite is allowed
settings.beginGroup( "/Qgis/connections-wfs" );
settings.setValue( QString( "/" + connectionName + "/url" ) , child.attribute( "url" ) );
settings.setValue( QString( "/" + connectionName + "/referer" ), child.attribute( "referer" ) );
settings.endGroup();

if ( !child.attribute( "username" ).isEmpty() )
@@ -55,10 +55,11 @@ QgsNewHttpConnection::QgsNewHttpConnection(
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );

txtReferer->setText( settings.value( key + "/referer" ).toString() );

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/" )
@@ -159,9 +160,10 @@ void QgsNewHttpConnection::accept()
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
}

settings.setValue( key + "/referer", txtReferer->text() );

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

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

@@ -36,7 +36,7 @@ QgsWFSCapabilities::QgsWFSCapabilities( QString theUri ) :
mBaseUrl = prepareUri( mUri.param( "url" ) );

QgsDebugMsg( "mBaseUrl = " + mBaseUrl );

//find out the server URL
/*
QSettings settings;
@@ -142,10 +142,20 @@ void QgsWFSCapabilities::requestCapabilities()

QNetworkRequest request( uriGetCapabilities() );
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
setReferer( request );
mCapabilitiesReply = QgsNetworkAccessManager::instance()->get( request );
connect( mCapabilitiesReply, SIGNAL( finished() ), this, SLOT( capabilitiesReplyFinished() ) );
}

void QgsWFSCapabilities::setReferer( QNetworkRequest &request ) const
{
QString referer = mUri.param( "referer" );
if ( !referer.isNull() )
{
request.setRawHeader( "Referer", QString( "%1" ).arg( referer ).toAscii() );
}
}

void QgsWFSCapabilities::capabilitiesReplyFinished()
{
// handle network errors
@@ -21,6 +21,7 @@
#include "qgsdatasourceuri.h"

class QNetworkReply;
class QNetworkRequest;

class QgsWFSCapabilities : public QObject
{
@@ -47,7 +48,10 @@ class QgsWFSCapabilities : public QObject

//! start network connection to get capabilities
void requestCapabilities();


//! set referer header
void setReferer( QNetworkRequest &request ) const;

//! description of a vector layer
struct FeatureType
{
@@ -67,7 +67,7 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) :
mUri.setParam( "password", password );
}

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

0 comments on commit ade381f

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