Skip to content

Commit 72d06e7

Browse files
authored
Merge pull request #739 from jooby-project/730
Jooby overriding Content-Type header fix #730
2 parents 66769a7 + 075ee1d commit 72d06e7

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.jooby.issues;
2+
3+
import org.jooby.test.ServerFeature;
4+
import org.junit.Test;
5+
6+
public class Issue730 extends ServerFeature {
7+
8+
{
9+
get("/730", (req, rsp) -> {
10+
rsp.header("content-type", "application/json");
11+
rsp.send("{\"issue\": \"730\"}");
12+
});
13+
14+
}
15+
16+
@Test
17+
public void contentTypeShouldWorkFromSetHeader() throws Exception {
18+
request().get("/730")
19+
.execute()
20+
.header("Content-Type", "application/json;charset=utf-8");
21+
}
22+
23+
}

jooby/src/main/java/org/jooby/internal/ResponseImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ private Response setHeader(final String name, final Object value) {
446446
}
447447
rsp.header(LOCATION, location);
448448
} else {
449+
if ("Content-Type".equalsIgnoreCase(name)) {
450+
// keep type reference
451+
this.type = MediaType.valueOf(value.toString());
452+
}
449453
rsp.header(name, Headers.encode(value));
450454
}
451455
}

0 commit comments

Comments
 (0)