Skip to content

Conversation

@jthetzel
Copy link

@jthetzel jthetzel commented Nov 23, 2025

This pull request allows contextily users to pass an optional headers parameter that will be included in the _retryer function's request.get call to the tile server.

We use titiler with cloud optimized geotiffs for tiles and often authenticate the titiler server with an authentication bearer token in the http request headers. This change allows us to use contextily with our authenticated titiler.

Opening this pull request for discussion in case it is of use to others. Please let me know if there is a simpler way to use contextily with custom headers.

Related issue: #267

> contextily/tests/test_cx.py:806: RuntimeWarning: More than 20
 figures have been opened. Figures created through the pyplot
 interface (`matplotlib.pyplot.figure`) are retained until explicitly
 closed and may consume too much memory. (To control this warning,
 see the rcParam `figure.max_open_warning`). Consider using
 `matplotlib.pyplot.close()`.
@jthetzel
Copy link
Author

jthetzel commented Nov 23, 2025

This also updates two unrelated pytest expected sums which were failing ( 4cfa350 ).

I can reproduce the pytest failure in the main branch head ( 851b77b ) to confirm it is unrelated to this pull request, to the best of my understanding.

@jthetzel
Copy link
Author

This also removes an unrelated matplotlib pytest warning ( ad65bcb ).

Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think this approach is fine. Just one comment - can we catch a situation when a user passes custom user-agent in headers?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants