Skip to content

✨ feat: add option to save additional headers when recording #773

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iamrajjoshi
Copy link
Member

@iamrajjoshi iamrajjoshi commented Jul 22, 2025

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Other

Description

Add the ability to record additional headers when recording responses.

Before I make changes to README.md and CHANGES, want to first make sure there is appetite for this.

Related Issues

PR checklist

Before submitting this pull request, I have done the following:

Added/updated tests?

Current repository has 100% test coverage.

  • Yes
  • No, and this is why:
  • I need help with writing tests

@iamrajjoshi iamrajjoshi requested a review from markstory July 22, 2025 04:06
@iamrajjoshi iamrajjoshi self-assigned this Jul 22, 2025
@iamrajjoshi iamrajjoshi marked this pull request as ready for review July 29, 2025 17:11
@@ -64,6 +75,7 @@ def _dump(
registered: "List[BaseResponse]",
destination: "Union[BinaryIO, TextIOWrapper]",
dumper: "Callable[[Union[Dict[Any, Any], List[Any]], Union[BinaryIO, TextIOWrapper]], Any]",
additional_headers: "Optional[List[str]]" = None,
Copy link
Member

Choose a reason for hiding this comment

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

Should this be include_headers or capture_headers? On first read my interpretation was that these headers would be added into the recorded responses.

self,
*,
file_path: "Union[str, bytes, os.PathLike[Any]]" = "response.yaml",
additional_headers: "Optional[List[str]]" = None,
Copy link
Member

Choose a reason for hiding this comment

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

Same here with include_headers, capture_headers or retain_headers 🤷


@_recorder.record(
file_path=self.out_file,
additional_headers=["Authorization", "X-Custom-Header", "Date"],
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
additional_headers=["Authorization", "X-Custom-Header", "Date"],
include_headers=["Authorization", "X-Custom-Header", "Date"],

I think this reads better, what do 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.

recorder doesn't record Date header
2 participants