IHttpResponseHandler respHdl = new IHttpResponseHandler() {
public void onResponse(IHttpResponse response) throws IOException {
IHttpResponse newResponse = new HttpResponse(response.getStatus(), response.getContentType(), response.getBody());
exchange.send(newResponse);
}
public void onException(IOException ioe) throws IOException {
exchange.sendError(ioe);
}
};
exchange.forward(exchange.getRequest(), respHdl);
}
};
client.addInterceptor(reqHdl);
GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
request.setHeader("Upgrade", "WebSocket");
request.setHeader("Connection", "upgrade");
request.setHeader("Origin", "http://websockets.org:" + server.getLocalPort());
IHttpResponse response = client.call(request);
IHttpConnection con = (IHttpConnection) response.getAttribute("org.xlightweb.client.connection");
Assert.assertTrue(con.isOpen());
client.close();
server.close();
}