use of com.sun.net.httpserver.Headers in project spf4j by zolyfarkas.
the class TcpServerTest method createHttpServer.
@BeforeClass
public static void createHttpServer() throws IOException {
server = HttpServer.create(new InetSocketAddress(TEST_PORT), 0);
server.createContext("/", new HttpHandler() {
@Override
public void handle(final HttpExchange he) throws IOException {
Headers respHeaders = he.getResponseHeaders();
respHeaders.add("testheader", "testValue");
he.sendResponseHeaders(200, 0);
OutputStream responseBody = he.getResponseBody();
responseBody.write("Some Body".getBytes(StandardCharsets.UTF_8));
responseBody.close();
}
});
server.start();
}
Aggregations