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

Support customized HTTP Request Headers #337

Merged
merged 3 commits into from
Feb 1, 2023

Conversation

justinabrokwah-okta
Copy link
Contributor

@justinabrokwah-okta justinabrokwah-okta commented Jan 31, 2023

For OKTA-525379:

  • Problem has been raised in a number of GH issues that custom headers do not overwrite the default ones, especially the Accept header which defaults to application/json
  • Fix problem where sometimes headers weren't being overwritten correctly
  • Add test to verify

- Fix problem where sometimes headers weren't being overwritten correctly
- Add test to verify
@justinabrokwah-okta justinabrokwah-okta marked this pull request as ready for review January 31, 2023 21:30
Comment on lines +121 to +122
headers = {**self._custom_headers, **headers}
headers = {**self._default_headers, **headers}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The **syntax destructures the dictionaries and prioritizes entries in the headers parameter set by the user

Comment on lines +117 to +123
@pytest.mark.parametrize(
"accept_header",
["", "application/xml", "application/json",
"text/html", "application/xhtml+xml", "image/jpeg"]
)
@pytest.mark.asyncio
async def test_overwrite_default_request_executor_headers(accept_header):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parametrized test added to test out various Accept headers

@justinabrokwah-okta justinabrokwah-okta merged commit 91ec384 into master Feb 1, 2023
@bryanapellanes-okta bryanapellanes-okta deleted the jabro-okta-525379-fix-request-headers branch December 12, 2023 15:48
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