Skip to content

Commit

Permalink
WMTS/WMS-C: remove Cache-Control header from tile requests to force c…
Browse files Browse the repository at this point in the history
…ache usage
  • Loading branch information
jef-n committed May 17, 2012
1 parent f3330e6 commit d28b655
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -728,8 +728,8 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i

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

#if QGISDEBUG
int n = ( col1 - col0 + 1 ) * ( row1 - row0 + 1 );
Expand Down Expand Up @@ -965,6 +965,19 @@ void QgsWmsProvider::tileReplyFinished()
.arg( QString::fromUtf8( pair.second ) ), 3 );
}
#endif

QNetworkCacheMetaData cmd = QgsNetworkAccessManager::instance()->cache()->metaData( reply->request().url() );

QNetworkCacheMetaData::RawHeaderList hl;
foreach( const QNetworkCacheMetaData::RawHeader &h, cmd.rawHeaders() )
{
if( h.first != "Cache-Control" )
hl.append( h );
}
cmd.setRawHeaders( hl );

QgsNetworkAccessManager::instance()->cache()->updateMetaData( cmd );

int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ) ).toInt();
int tileNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ) ).toInt();
QRectF r = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ) ).toRectF();
Expand Down Expand Up @@ -1093,7 +1106,7 @@ void QgsWmsProvider::tileReplyFinished()
}
else
{
QgsMessageLog::logMessage( tr( "Reply to earlier tile request received too late [%1]" ).arg( reply->url().toString() ), tr( "WMS" ) );
QgsDebugMsg( QString( "Reply too late [%1]" ).arg( reply->url().toString() ) );
}

mTileReplies.removeOne( reply );
Expand Down

0 comments on commit d28b655

Please sign in to comment.