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

[DRAFT] Add a way to retrieve response headers #87

Open
OdinsPlasmaRifle opened this issue Nov 24, 2021 · 3 comments
Open

[DRAFT] Add a way to retrieve response headers #87

OdinsPlasmaRifle opened this issue Nov 24, 2021 · 3 comments

Comments

@OdinsPlasmaRifle
Copy link
Contributor

OdinsPlasmaRifle commented Nov 24, 2021

Add a way to get response headers after getting a response from an API call. We need to be able to get information from headers like Idempotent-Replayed after returning a response in the SDK.

Additionally, it may be a good idea to make all "response data" including the raw response body available to developers who use the SDK. Currently only the resource is returned in a response (or an error is thrown). It could be a good idea to allow developers to introspect the actual response object for additional info (such as headers, response body and other details that the requests library may include after running an http request).

@OdinsPlasmaRifle
Copy link
Contributor Author

OdinsPlasmaRifle commented Nov 8, 2022

Can you explore if there is a way to get additional info like this after calling an SDK method. It is possible this would require backwards incompatible changes but it would be good to see how we can achieve it. Please make some design suggestions for how this could work from an SDK usage point of view.

@OdinsPlasmaRifle OdinsPlasmaRifle changed the title Add a way to get response headers Investigate a way to retrieve response headers Nov 14, 2022
@OdinsPlasmaRifle
Copy link
Contributor Author

It looks like Stripe (who we have used for inspiration before) decided to do it like this: stripe/stripe-python#371

I am not sure I agree with calling it last_response though. Wouldn't just response be adequate? Please check this info out and see if you can figure out a similar solution.

@almabud2
Copy link
Contributor

In my opinion,

  • We can use context manager though this solution is rejected in the stripe issue. I don't think the situation they have mentioned is going to happen in the rehive sdk.
  • Another suitable solution (most probably the best one in my thoughts) introducing a global variable in the resources eg. last_response and we could store the headers there.
    The above solution will be backward competible as we are not changing the actual response.
  • Another one but it is not backward compatible, we could wrap our responses in a class RehiveResponse and do our response-related stuff there. Like decoding error raising and we can insert the request header there. This will help to introduce some specialized attributes easily. eg. idempotent_replayed and thus we could control the response.

@OdinsPlasmaRifle OdinsPlasmaRifle changed the title Investigate a way to retrieve response headers [DRAFT] Add a way to retrieve response headers Dec 12, 2022
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

2 participants