-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set additional HTTP headers for WCS provider (qgis#59635)
* Set additional HTTP headers for WCS provider Same way as done for WMS Fixes partially qgis#17823 (WFS still missing) * Move qgsauthorizationsettings.h to core/auth * qgsauthorizationsettings.h SIP_NO_FILE * Add class documentation * Add CORE_EXPORT * switcht to class * Move implementation to cpp file * fix indentation --------- Co-authored-by: Denis Rouzaud <[email protected]>
- Loading branch information
Showing
11 changed files
with
95 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*************************************************************************** | ||
qgsauthorizationsettings.cpp | ||
--------------------- | ||
begin : December 2024 | ||
copyright : (C) 2024 by Damiano Lombardi | ||
email : damiano at opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsauthorizationsettings.h" | ||
|
||
QgsAuthorizationSettings::QgsAuthorizationSettings( const QString &userName, const QString &password, const QgsHttpHeaders &httpHeaders, const QString &authcfg ) | ||
: mUserName( userName ) | ||
, mPassword( password ) | ||
, mHttpHeaders( httpHeaders ) | ||
, mAuthCfg( authcfg ) | ||
{} | ||
|
||
bool QgsAuthorizationSettings::setAuthorization( QNetworkRequest &request ) const | ||
{ | ||
if ( !mAuthCfg.isEmpty() ) // must be non-empty value | ||
{ | ||
return QgsApplication::authManager()->updateNetworkRequest( request, mAuthCfg ); | ||
} | ||
else if ( !mUserName.isEmpty() || !mPassword.isEmpty() ) | ||
{ | ||
request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toUtf8().toBase64() ); | ||
} | ||
|
||
mHttpHeaders.updateNetworkRequest( request ); | ||
|
||
return true; | ||
} | ||
|
||
bool QgsAuthorizationSettings::setAuthorizationReply( QNetworkReply *reply ) const | ||
{ | ||
if ( !mAuthCfg.isEmpty() ) | ||
{ | ||
return QgsApplication::authManager()->updateNetworkReply( reply, mAuthCfg ); | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.