Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document ability to send arbitrary HTTP headers to WMTS etc. sites #2052

Open
jidanni opened this issue Nov 25, 2019 · 4 comments
Open

Document ability to send arbitrary HTTP headers to WMTS etc. sites #2052

jidanni opened this issue Nov 25, 2019 · 4 comments

Comments

@jidanni
Copy link
Contributor

jidanni commented Nov 25, 2019

https://gdal.org/drivers/raster/wmts.html features many HTTP headers one can send in a request.
However one never knows when a site might need some other arbitrary header to get it to respond.
E.g., "Cookie: ...."

Therefore please add the ability to add arbitrary HTTP headers to WMTS etc. sites.

@jratike80
Copy link
Collaborator

I can read from https://gdal.org/user/virtual_file_systems.html

Starting with GDAL 2.3, additional HTTP headers can be sent by setting the GDAL_HTTP_HEADER_FILE configuration option to point to a filename of a text file with “key: value” HTTP headers.

This config option is not listed in https://trac.osgeo.org/gdal/wiki/ConfigOptions. I wonder if it affects only vsi* systems or would it work also with the drivers which are using curl. If it does not work then perhaps re-using GDAL_HTTP_HEADER_FILE could be the way to implement the support.

@rouault
Copy link
Member

rouault commented May 14, 2020

I wonder if it affects only vsi* systems or would it work also with the drivers which are using curl

Ah, good catch that can indeed work:

$ echo "foo: bar" > /tmp/header.txt
$ rm -rf gdalwmscache
$ CPL_CURL_VERBOSE=YES GDAL_HTTP_HEADER_FILE=/tmp/header.txt gdal_translate frmts/wms/frmt_wms_openstreetmap_tms.xml out.tif -outsize 256 256 --debug on
[...]
> GET /0/0/0.png HTTP/1.1
Host: tile.openstreetmap.org
User-Agent: GDAL WMS driver (http://www.gdal.org/frmt_wms.html)
Accept: */*
foo: bar
[...]

jidanni added a commit to jidanni/gdal that referenced this issue May 16, 2020
Just one of the many places needed to be fixed for OSGeo#2052 .
P.S., UNTESTED.
@jidanni jidanni changed the title Add ability to send arbitrary HTTP headers to WMTS etc. sites Document ability to send arbitrary HTTP headers to WMTS etc. sites May 16, 2020
jidanni added a commit to jidanni/gdal that referenced this issue May 16, 2020
jidanni added a commit to jidanni/gdal that referenced this issue May 16, 2020
rouault pushed a commit that referenced this issue May 16, 2020
…vis] [skip appveyor]

Just one of the many places needed to be fixed for #2052 .
P.S., UNTESTED.
rouault pushed a commit that referenced this issue May 16, 2020
rouault pushed a commit that referenced this issue May 16, 2020
…ip travis] [skip appveyor]

For #2052. UNTESTED by me.
jidanni added a commit to jidanni/gdal that referenced this issue May 20, 2020
Example from OSGeo#2052 to assist with OSGeo#2571 .
P.S., :decl_configoption: is not getting parsed for me. Please fix it.
Yes, I used U+0060 GRAVE ACCENT
jidanni added a commit to jidanni/gdal that referenced this issue May 20, 2020
Helping to finish OSGeo#2571 via guess as how example from OSGeo#2052 works.
No I cannot tell if this will format correctly when rendered in HTML.
rouault pushed a commit that referenced this issue May 20, 2020
…p travis] [skip appveyor]

Helping to finish #2571 via guess as how example from #2052 works.
No I cannot tell if this will format correctly when rendered in HTML.
@jratike80
Copy link
Collaborator

@jidanni is this now documented well enough?

@jidanni
Copy link
Contributor Author

jidanni commented Oct 21, 2023

Add an example of how to add a cookie to a request. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants