Skip to content

Commit b09fb37

Browse files
committedOct 4, 2017
[bugfix] Do not cache invalid WM(T)S responses
The problem here was that in case of http->https redirect from a misconfigured server (that advertizes http and then redirects all request to https) all http redirect requests were cached, making all subsequent requests to the same url hit the 301 Moved Permanently reponse page intead of the redirected content. Fixes #16427 WMTS rendering problems in 2.18 and Master cherry-picked from d102404
1 parent f14502e commit b09fb37

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎src/providers/wms/qgstilecache.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ void QgsTileCache::insertTile( const QUrl& url, const QImage& image )
3333
bool QgsTileCache::tile( const QUrl& url, QImage& image )
3434
{
3535
QMutexLocker locker( &sTileCacheMutex );
36-
if ( QImage* i = sTileCache.object( url ) )
36+
bool success = false;
37+
if ( QImage *i = sTileCache.object( url ) )
3738
{
3839
image = *i;
39-
return true;
40+
success = true;
4041
}
4142
else if ( QgsNetworkAccessManager::instance()->cache()->metaData( url ).isValid() )
4243
{
@@ -48,10 +49,13 @@ bool QgsTileCache::tile( const QUrl& url, QImage& image )
4849
image = QImage::fromData( imageData );
4950

5051
// cache it as well (mutex is already locked)
51-
sTileCache.insert( url, new QImage( image ) );
52-
53-
return true;
52+
// Check for null because it could be a redirect (see: https://issues.qgis.org/issues/16427 )
53+
if ( ! image.isNull( ) )
54+
{
55+
sTileCache.insert( url, new QImage( image ) );
56+
success = true;
57+
}
5458
}
5559
}
56-
return false;
60+
return success;
5761
}

0 commit comments

Comments
 (0)
Please sign in to comment.