Let mock server write response in UTF-8
This commit is contained in:
parent
dbfb3727af
commit
57a6e06ac0
3 changed files with 45 additions and 6 deletions
|
@ -4,9 +4,10 @@ import com.sun.net.httpserver.HttpExchange
|
|||
|
||||
class Util {
|
||||
static void createResponse(HttpExchange ex, String response, int statusCode) {
|
||||
ex.sendResponseHeaders(statusCode, response ? response.length() : -1)
|
||||
byte[] responseBytes = response ? response.getBytes('UTF-8') : new byte[0]
|
||||
ex.sendResponseHeaders(statusCode, responseBytes.length ?: -1)
|
||||
if (response) {
|
||||
ex.responseBody << response
|
||||
ex.responseBody << responseBytes
|
||||
ex.responseBody.close()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue