Skip to content
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

[BUG] The content type of the request takes precedence over the default content-type when determining the response content-type #5

Open
lestephane opened this issue Jul 6, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@lestephane
Copy link

Describe the bug

in MapMateSerializerAndDeserializer at line 93, the content-type of the response is hijacked by the content-type of the request (if present).

if (!contentType.isEmpty()) {
    responseContentType = contentType;
} else {
    responseContentType = defaultContentType;
}

This leads to awkward behaviour. For example, in the case where the incoming request is application/x-www-form-urlencoded, and I've configured

httpmate.assumingTheDefaultContentType(ContentType.json())

httpmate attempts to marshall the response to application/x-www-form-urlencoded, which is not the expected behaviour.

To Reproduce

....mappingRequestsAndResponsesUsing(mapMate()
        .matchingTheContentType(fromString("application/x-www-form-urlencoded"))
            .toTheMarshallerType(marshallingType("application/x-www-form-urlencoded"))
        .assumingTheDefaultContentType(ContentType.json())
            .usingTheSerializer(...)
            .andTheDeserializer(...))

Expected behavior

Expected the response content-type to be the content type specified in assumingTheDefaultContentType(...), as there is to my knowledger no way to specify the response content-type in any other way at the moment (The concept of a HttpMateChainKeys.RESPONSE_CONTENT_TYPE separate from HttpMateChainKeys.CONTENT_TYPE does not exist yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants