Skip to content

Commit d28b655

Browse files
committed
WMTS/WMS-C: remove Cache-Control header from tile requests to force cache usage
1 parent f3330e6 commit d28b655

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/providers/wms/qgswmsprovider.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
728728

729729
int col0 = qBound( minTileCol, ( int ) floor(( viewExtent.xMinimum() - tm->topLeft.x() ) / twMap ), maxTileCol );
730730
int row0 = qBound( minTileRow, ( int ) floor(( tm->topLeft.y() - viewExtent.yMaximum() ) / thMap ), maxTileRow );
731-
int col1 = qBound( minTileCol, ( int ) ceil(( viewExtent.xMaximum() - tm->topLeft.x() ) / twMap ), maxTileCol );
732-
int row1 = qBound( minTileRow, ( int ) ceil(( tm->topLeft.y() - viewExtent.yMinimum() ) / thMap ), maxTileRow );
731+
int col1 = qBound( minTileCol, ( int ) floor(( viewExtent.xMaximum() - tm->topLeft.x() ) / twMap ), maxTileCol );
732+
int row1 = qBound( minTileRow, ( int ) floor(( tm->topLeft.y() - viewExtent.yMinimum() ) / thMap ), maxTileRow );
733733

734734
#if QGISDEBUG
735735
int n = ( col1 - col0 + 1 ) * ( row1 - row0 + 1 );
@@ -965,6 +965,19 @@ void QgsWmsProvider::tileReplyFinished()
965965
.arg( QString::fromUtf8( pair.second ) ), 3 );
966966
}
967967
#endif
968+
969+
QNetworkCacheMetaData cmd = QgsNetworkAccessManager::instance()->cache()->metaData( reply->request().url() );
970+
971+
QNetworkCacheMetaData::RawHeaderList hl;
972+
foreach( const QNetworkCacheMetaData::RawHeader &h, cmd.rawHeaders() )
973+
{
974+
if( h.first != "Cache-Control" )
975+
hl.append( h );
976+
}
977+
cmd.setRawHeaders( hl );
978+
979+
QgsNetworkAccessManager::instance()->cache()->updateMetaData( cmd );
980+
968981
int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ) ).toInt();
969982
int tileNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ) ).toInt();
970983
QRectF r = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ) ).toRectF();
@@ -1093,7 +1106,7 @@ void QgsWmsProvider::tileReplyFinished()
10931106
}
10941107
else
10951108
{
1096-
QgsMessageLog::logMessage( tr( "Reply to earlier tile request received too late [%1]" ).arg( reply->url().toString() ), tr( "WMS" ) );
1109+
QgsDebugMsg( QString( "Reply too late [%1]" ).arg( reply->url().toString() ) );
10971110
}
10981111

10991112
mTileReplies.removeOne( reply );

0 commit comments

Comments
 (0)