Skip to content

Commit

Permalink
Fix tiktoken request
Browse files Browse the repository at this point in the history
  • Loading branch information
Askir committed Oct 25, 2024
1 parent abb862f commit f4a0aa3
Show file tree
Hide file tree
Showing 2 changed files with 201,065 additions and 396 deletions.
31 changes: 0 additions & 31 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,9 @@


def remove_set_cookie_header(response: dict[str, Any]):
"""
Removes the Set-Cookie header from a VCR.py response object to improve cassette consistency.
This function can be used as a before_record callback in your VCR configuration
to ensure that Set-Cookie headers are stripped from responses before they are
recorded to cassettes.
Args:
response (vcr.request.Response): The VCR.py response object to modify
Returns:
vcr.request.Response: The modified response object with Set-Cookie headers removed
Example:
import vcr
# Configure VCR with the callback
vcr = vcr.VCR(
before_record_response=remove_set_cookie_header,
match_on=['uri', 'method']
)
with vcr.use_cassette('tests/fixtures/my_cassette.yaml'):
# Make your HTTP requests here
pass
"""

# Get the headers from the response
headers = response["headers"]

# Headers to remove (case-insensitive)
headers_to_remove = ["set-cookie", "Set-Cookie"]

# Remove Set-Cookie headers if they exist
for header in headers_to_remove:
if header in headers:
del headers[header]
Expand Down
Loading

0 comments on commit f4a0aa3

Please sign in to comment.