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

withContentType should set response encoding #64

Open
lukas-krecan opened this issue Aug 17, 2013 · 2 comments
Open

withContentType should set response encoding #64

lukas-krecan opened this issue Aug 17, 2013 · 2 comments
Assignees
Milestone

Comments

@lukas-krecan
Copy link
Contributor

When using respond().withContentType("text/plain; charset=CP1250") I would expect that response encoding will be set automatically based on the content type.

@jandudek jandudek added this to the 1.2.0 milestone Jun 8, 2014
@jandudek jandudek self-assigned this Jun 8, 2014
@jandudek
Copy link
Contributor

jandudek commented Dec 3, 2015

Right now the withContentType method is a shorthand version for withHeader("ContentType", value) and therefore doesn't parse the value at all. If you want to specify the encoding explicitly (and not use the UTF-8 default), you have to call the withEncoding method.

This allows to simulate a faulty server which claims the response is in a specific encoding (using the Content-Type header) however the body is in fact encoded using a different encoding. It is an edge case, definitely, but it may be handy.

Do you have any suggestions? Should Jadler support this edge case? Any ideas to make this more user friendly?

@jandudek jandudek removed this from the 1.2.0 milestone Dec 6, 2015
@jandudek jandudek added this to the 2.0.0 milestone Jan 27, 2016
@Kreinoee
Copy link

Kreinoee commented Mar 7, 2016

I agree with @jandudek. Som servers just behave badle, and id should be possibly to stub out such a server with jadler.

So if this should be implemented, it should somehow be made optional. This could be done by a making a overloaded version taking an ekstra boolean flag, or mayby an EnumSet if more switches like this is expected over time:

respond().withContentType(
    "text/plain; charset=CP1250", 
    EnumSet.of(withContentTypeSwitches.AUTO_SET_ENCODING))

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

No branches or pull requests

3 participants