eclipse-ee4j / eclipse-ee4j/jersey

Charset dropped for content-type text/html

Open
#2,209 4 comments 0 reactions 0 assignees View on GitHub
Component: core Priority: Minor Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

In Jersey 2.0/GlassFish 4.0 there seems to be some weird behavior when specifying the **charset** in a @Produces annotation:

```
@Path(...) @Produces("text/html; charset=utf-8") // Charset gets dropped public Response get() {
return Response.ok("Test");
}
```

This will **drop the charset** from the response and only return _text/html_. However, if you change the content type to anything other than _text/html_ the charset will be left intact:

```
@Path(...) @Produces("text/plain; charset=utf-8") // Charset won't get dropped public Response get() {
return Response.ok("Test");
}
```

The only way I've found to keep the charset with _text/html_, is to specify it in the response like so:

```
@Path(...)
public Response get() {
return Response.ok("Test", "text/html; charset=utf-8"); // Charset won't get dropped }
```

Cheers
#### Environment
Jersey 2.0, GlassFish 4.0, NetBeans 7.3.1, Windows 8.
#### Affected Versions
[2.0]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.