Skip to content

Normalize response media types before decoding - #52

Open
ItsM0rty wants to merge 1 commit into
serpapi:masterfrom
ItsM0rty:code-fix/response-media-type
Open

ItsM0rty wants to merge 1 commit into
serpapi:masterfrom
ItsM0rty:code-fix/response-media-type

Conversation

@ItsM0rty

@ItsM0rty ItsM0rty commented Dec 2, 2026

Copy link
Copy Markdown

Fixes #51.

search(output: 'md') or search(output: 'html') could try to parse the response as JSON when a valid Content-Type used different casing or whitespace before charset. Normalize the media type before choosing the decoder.

Both cases fail on master in the mocked Ruby probe and pass w/ the fix. The offline RSpec run passed 35 examples w/o calling the live API.

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.

Valid Content-Type headers can make search parse HTML or Markdown as JSON

1 participant