Opened 13 years ago

Closed 13 years ago

#3464 closed defect (fixed)

gdal_translate cannot download from WMS interface at

Reported by: voland Owned by: nowakpl
Priority: normal Milestone: 1.8.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: WMS useragent
Cc: warmerdam

Description (last modified by warmerdam)

There is a WMS service in Czech Republic. It can be configured the following way:

<Service name="WMS">








It can be run with the following command:

gdal_translate -of ENVI wms.xml test.envi

The very first URL generated by gdal_translate cannot be downloaded:

Input file size is 2500, 3000
0ERROR 1: GDALWMS: Unable to download block 0, 0.
  HTTP status code: 200, error: (null).
ERROR 1: IReadBlock failed at X offset 0, Y offset 0
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 0

But if opened in Firefox, this URL is downloaded immediately.

It is possible that gdal_translate is missing something in HTTP Header like user agent, session ID or something that allows WMS server to check if it is a web browser or other piece of software.

Attachments (1)

ticket_3464.patch (4.0 KB ) - added by Even Rouault 13 years ago.
Adds a <UserAgent> option

Download all attachments as: .zip

Change History (7)

comment:1 by warmerdam, 13 years ago

Cc: warmerdam added
Component: defaultGDAL_Raster
Description: modified (diff)
Keywords: WMS added
Owner: changed from warmerdam to nowakpl


Would you be interested in investigating this? If not, reassign back to me, and perhaps I can have Chaitanya look into it.

comment:2 by Even Rouault, 13 years ago

Voland, yes, your guess is right. That server expects the User-Agent field to be a well-known string, such as "Mozilla/5.0" whereas we currently fill it with "GDAL WMS driver (".

Adam, I've attached a patch that provides a new <UserAgent> option to the GDAL WMS XML syntax. I'm not sure if it wouldn't be simpler to just default to "Mozilla/5.0" or some other common browser instead of the "GDAL WMS driver..." string ?

by Even Rouault, 13 years ago

Attachment: ticket_3464.patch added

Adds a <UserAgent> option

comment:3 by nowakpl, 13 years ago

I don't think lying to the server is a good idea.

in reply to:  3 comment:4 by voland, 13 years ago

I don't think lying to the server is a good idea.

But it is not a criminal offense to let user decide what "User Agent" they want to use, especially in such rare cases like

comment:5 by warmerdam, 13 years ago

I see no harm in letting folks override the user agent, but I would not want the default to be "mozilla". I think the current described and distinct user agent string is the appropriate default.

comment:6 by Even Rouault, 13 years ago

Keywords: useragent added
Milestone: 1.8.0
Resolution: fixed
Status: newclosed

r19082 /trunk/gdal/frmts/wms/ (5 files): WMS driver : adds a <UserAgent> optional parameter so that the user be able to provide its own useragent string for picky WMS servers (#3464)

Note: See TracTickets for help on using tickets.