Skip to content

Commit

Permalink
wms provider: also accept application/octet-stream as image content type
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 28, 2013
1 parent a4d8313 commit 4f397f2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,8 @@ void QgsWmsProvider::tileReplyFinished()

QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
QgsDebugMsg( "contentType: " + contentType );
if ( !contentType.startsWith( "image/", Qt::CaseInsensitive ) )
if ( !contentType.startsWith( "image/", Qt::CaseInsensitive ) &&
contentType.compare( "application/octet-stream", Qt::CaseInsensitive ) != 0 )
{
QByteArray text = reply->readAll();
if ( contentType.toLower() == "text/xml" && parseServiceExceptionReportDom( text ) )
Expand Down Expand Up @@ -1188,7 +1189,8 @@ void QgsWmsProvider::tileReplyFinished()
}
else
{
QgsMessageLog::logMessage( tr( "Returned image is flawed [%1]" ).arg( reply->url().toString() ), tr( "WMS" ) );
QgsMessageLog::logMessage( tr( "Returned image is flawed [Content-Type:%1; URL: %2]" )
.arg( contentType ).arg( reply->url().toString() ), tr( "WMS" ) );
}
}
else
Expand Down Expand Up @@ -1263,7 +1265,8 @@ void QgsWmsProvider::cacheReplyFinished()

QString contentType = mCacheReply->header( QNetworkRequest::ContentTypeHeader ).toString();
QgsDebugMsg( "contentType: " + contentType );
if ( contentType.startsWith( "image/", Qt::CaseInsensitive ) )
if ( contentType.startsWith( "image/", Qt::CaseInsensitive ) ||
contentType.compare( "application/octet-stream", Qt::CaseInsensitive ) == 0 )
{
QImage myLocalImage = QImage::fromData( mCacheReply->readAll() );
if ( !myLocalImage.isNull() )
Expand All @@ -1273,7 +1276,8 @@ void QgsWmsProvider::cacheReplyFinished()
}
else
{
QgsMessageLog::logMessage( tr( "Returned image is flawed [%1]" ).arg( mCacheReply->url().toString() ), tr( "WMS" ) );
QgsMessageLog::logMessage( tr( "Returned image is flawed [Content-Type:%1; URL:%2]" )
.arg( contentType ).arg( mCacheReply->url().toString() ), tr( "WMS" ) );
}
}
else
Expand All @@ -1287,9 +1291,10 @@ void QgsWmsProvider::cacheReplyFinished()
}
else
{
QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Response: %2; URL:%3)" )
QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Response: %2; Content-Type: %3; URL:%4)" )
.arg( status.toInt() )
.arg( QString::fromUtf8( text ) )
.arg( contentType )
.arg( mCacheReply->url().toString() ), tr( "WMS" ) );
}

Expand Down

0 comments on commit 4f397f2

Please sign in to comment.