Skip to content

Commit 4f397f2

Browse files
committedFeb 28, 2013
wms provider: also accept application/octet-stream as image content type
1 parent a4d8313 commit 4f397f2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed
 

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,8 @@ void QgsWmsProvider::tileReplyFinished()
11261126

11271127
QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
11281128
QgsDebugMsg( "contentType: " + contentType );
1129-
if ( !contentType.startsWith( "image/", Qt::CaseInsensitive ) )
1129+
if ( !contentType.startsWith( "image/", Qt::CaseInsensitive ) &&
1130+
contentType.compare( "application/octet-stream", Qt::CaseInsensitive ) != 0 )
11301131
{
11311132
QByteArray text = reply->readAll();
11321133
if ( contentType.toLower() == "text/xml" && parseServiceExceptionReportDom( text ) )
@@ -1188,7 +1189,8 @@ void QgsWmsProvider::tileReplyFinished()
11881189
}
11891190
else
11901191
{
1191-
QgsMessageLog::logMessage( tr( "Returned image is flawed [%1]" ).arg( reply->url().toString() ), tr( "WMS" ) );
1192+
QgsMessageLog::logMessage( tr( "Returned image is flawed [Content-Type:%1; URL: %2]" )
1193+
.arg( contentType ).arg( reply->url().toString() ), tr( "WMS" ) );
11921194
}
11931195
}
11941196
else
@@ -1263,7 +1265,8 @@ void QgsWmsProvider::cacheReplyFinished()
12631265

12641266
QString contentType = mCacheReply->header( QNetworkRequest::ContentTypeHeader ).toString();
12651267
QgsDebugMsg( "contentType: " + contentType );
1266-
if ( contentType.startsWith( "image/", Qt::CaseInsensitive ) )
1268+
if ( contentType.startsWith( "image/", Qt::CaseInsensitive ) ||
1269+
contentType.compare( "application/octet-stream", Qt::CaseInsensitive ) == 0 )
12671270
{
12681271
QImage myLocalImage = QImage::fromData( mCacheReply->readAll() );
12691272
if ( !myLocalImage.isNull() )
@@ -1273,7 +1276,8 @@ void QgsWmsProvider::cacheReplyFinished()
12731276
}
12741277
else
12751278
{
1276-
QgsMessageLog::logMessage( tr( "Returned image is flawed [%1]" ).arg( mCacheReply->url().toString() ), tr( "WMS" ) );
1279+
QgsMessageLog::logMessage( tr( "Returned image is flawed [Content-Type:%1; URL:%2]" )
1280+
.arg( contentType ).arg( mCacheReply->url().toString() ), tr( "WMS" ) );
12771281
}
12781282
}
12791283
else
@@ -1287,9 +1291,10 @@ void QgsWmsProvider::cacheReplyFinished()
12871291
}
12881292
else
12891293
{
1290-
QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Response: %2; URL:%3)" )
1294+
QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Response: %2; Content-Type: %3; URL:%4)" )
12911295
.arg( status.toInt() )
12921296
.arg( QString::fromUtf8( text ) )
1297+
.arg( contentType )
12931298
.arg( mCacheReply->url().toString() ), tr( "WMS" ) );
12941299
}
12951300

0 commit comments

Comments
 (0)
Please sign in to comment.