@Override
protected void doWrite(String encodedPacket) {
super.doWrite(encodedPacket);
String origin = request.headers().get("Origin");
MultiMap resHeaders = response.headers();
resHeaders.add("Content-Type", "text/plain; charset=UTF-8");
resHeaders.add("Content-Length", encodedPacket == null ? "0" : String.valueOf(encodedPacket.getBytes(Charset.forName("UTF-8")).length));
resHeaders.add("Connection", "Keep-Alive");
if(origin != null) {
// https://developer.mozilla.org/En/HTTP_Access_Control
resHeaders.add("Access-Control-Allow-Origin", origin);
resHeaders.add("Access-Control-Allow-Credentials", "true");
}
response.setStatusCode(200);
response.write(encodedPacket);
log.debug(this.getName() + " writing " + encodedPacket);