Skip to content

Conversation

@xrmx
Copy link
Contributor

@xrmx xrmx commented Dec 23, 2025

Description

This PR adds support to capture and sanitize custom client headers in the urllib instrumentation. While at it also fixed the instrumented Opener.open handling of headers if added via Opener.addheaders.

Refs #3962

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tox

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@xrmx xrmx marked this pull request as ready for review December 24, 2025 10:37
@xrmx xrmx requested a review from a team as a code owner December 24, 2025 10:37
@herin049
Copy link
Contributor

This work might belong in another PR, but it looks like there are some additional headers that are added by urllib in URLopener:_open_generic_http (e.g. auth, proxy and content type headers) that are not in addheaders. It seems like the only way to get all headers would be to wrap the request method directly. Let me know what you think.

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.

3 participants