Skip to content

JSON formatting ignores uppercase and mixed-case Content-Type values #1958

Description

@xu91102

JSON response formatting depends on the casing of the Content-Type value. A response with APPLICATION/JSON or Application/Problem+JSON; charset=utf-8 is left compact by http --pretty=format --body URL, while the equivalent lowercase type is formatted.

For a response body {"message":"ok"}, expected output is:

{
    "message": "ok"
}

Actual output retains {"message":"ok"} on one line. Media type names are case-insensitive. The JSON formatter's substring checks currently use the original case.

Reproduced through HTTPie's CLI entry with responses serving these exact content types, against master 5b604c3, Python 3.12.13 / macOS. Both new regressions fail on the original formatter.

Investigated with OpenAI Codex assistance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions