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

Inconsistent request preparation #629

Open
JustAnotherArchivist opened this issue Feb 14, 2024 · 0 comments
Open

Inconsistent request preparation #629

JustAnotherArchivist opened this issue Feb 14, 2024 · 0 comments

Comments

@JustAnotherArchivist
Copy link
Contributor

While working on my recent PR, I noticed that the request for uploading is prepared differently when debug mode is enabled. With debugging, it uses the session's prepare_request method:

if debug:
prepared_request = self.session.prepare_request(_build_request())
body.close()
return prepared_request

Without debugging, it uses the request's prepare method:

request = _build_request()
prepared_request = request.prepare()

I observed header differences between the two, but I can't immediately tell which is more correct, hence why I'm filing an issue rather than a PR. Note that the session.headers do get copied into the request directly inside _build_request. Changing the non-debug code to use self.session.prepare_request breaks several tests, too.

There's another case in Item.modify_metadata where the code directly contradicts the preceding comment:

# Must use Session.prepare_request to make sure session settings
# are used on request!
prepared_request = request.prepare()

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

No branches or pull requests

1 participant