Skip to content

Content Type being append with charset=ISO-8859-1 #1428

@rafaelrenanpacheco

Description

@rafaelrenanpacheco

Hello!

I'm updating a Spring Boot 2.2 app with Spring Cloud Hoxton.SR1 to Spring Boot 2.3 with Hoxton.SR5, and the provider tests started to fail. The test fail with the following message:

DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=ISO-8859-1' not supported]

Something is appending the charset=ISO-8859-1 to the Content-Type header, even tho our contract DSL sets it to application/json only:

Contract.make {
    description 'create something'
    request {
        method POST()
        url '/something'
        body(
            property: 'value'
        )
        headers {
            contentType(applicationJson()) // This is "application/json"
        }
    }
    response {
        status OK()
    }
}

I think UTF-8 is the default for Spring Boot 2.2 onward, so it was not necessary anymore to use applicationJsonUtf8() as content type. If I do change the content type to applicationJsonUtf8(), then that charset=ISO-8859-1 is not appended and the test pass.

Is appending a default charset an expected behavior for Spring Cloud Contract?

Best regards,
Rafael Pacheco.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions