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

Handle inconsistent header case for Mementos #101

Merged

Conversation

Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Oct 31, 2022

This fixes #98, which was caused by two changes:

  1. The Internet Archive now returns most archived header names (i.e. those prefixed with 'x-archive-org-') in lower-case.
  2. In HTTP/2 (now possible since we are using HTTPS as of Use HTTPS for all archive.org URLs #97), all headers are lower-case/case-insensitive.

Since that means it’s possible to wind up with different header name casing when running the same code on different systems, I had to go ahead and make the Memento.headers attribute case-insensitive (we probably should have done this long ago for user friendliness anyway). I've implemented that using code largely taken from Requests, since their implementation is not public so we can't just use it directly (plus we plan to switch of Requests at some point anyway). If we wind up switching to HTTPX, they do have a public implementation we can just use instead of this.

This also regenerates the cassette for the basic memento test, since the headers have changed.
This fixes #98, which was caused by two changes:

1. The Internet Archive now returns most *archived* header names (i.e. those prefixed with 'x-archive-org-') in lower-case.
2. In HTTP/2 (now possible since we are using HTTPS as of #97), *all* headers are lower-case/case-insensitive.

This also meant I needed to make the `Memento.headers` attribute case-insensitive. I've implemented that using code largely taken from Requests, since their implementation is not public so we can't just use it directly (plus we plan to switch of Requests at some point anyway).
Copy link
Member Author

@Mr0grog Mr0grog left a comment

Choose a reason for hiding this comment

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

Looks like docs.scipy.org is currently down, so intersphinx can’t fetch references. We should wait until it’s back before merging, but the docs build failure isn’t an issue in our code.

Side note: we definitely use the python.org references, but I’m not sure we need the scipy/numpy/pandas/matplotlib ones. We should pull them out if we don’t.

@Mr0grog Mr0grog mentioned this pull request Oct 31, 2022
@Mr0grog Mr0grog merged commit 0b2134b into main Nov 1, 2022
@Mr0grog Mr0grog deleted the 98-headers-casing-is-more-complicated-than-it-used-to-be branch November 1, 2022 19:17
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.

Some original headers are getting lost
1 participant