Skip to content

Commit 7c3e537

Browse files
committed
Specify UTF-8 charset in Content-Type
The default HTTP charset is ISO-8859-1 so we need to specify UTF-8, which is what is being sent to the client.
1 parent 9f9f308 commit 7c3e537

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void send(String contentType, String string) {
128128
mContentLength = bytes.length;
129129
mRawHeaders.set("Content-Length", Integer.toString(bytes.length));
130130
mRawHeaders.set("Content-Type", contentType);
131-
131+
132132
writeHead();
133133
mSink.write(ByteBuffer.wrap(string.getBytes()));
134134
onEnd();
@@ -150,12 +150,12 @@ protected void report(Exception e) {
150150
@Override
151151
public void send(String string) {
152152
responseCode(200);
153-
send("text/html", string);
153+
send("text/html; charset=utf8", string);
154154
}
155155

156156
@Override
157157
public void send(JSONObject json) {
158-
send("application/json", json.toString());
158+
send("application/json; charset=utf8", json.toString());
159159
}
160160

161161
public void sendFile(File file) {

0 commit comments

Comments
 (0)