Write the response output

Report a typo

What will be the output of the response with this method if your URI is http://127.0.0.1:8080/home?language=Java?

public Headers handleGetRequest(HttpExchange exchange) throws IOException {
    String response = "I know " +  exchange.getRequestURI().toString().split("=")[1];

    exchange.sendResponseHeaders(200, response.getBytes().length);
    exchange.getResponseHeaders().set("Access-Control-Allow-Origin", "*");
    
    try (OutputStream stream = exchange.getResponseBody()) {
        stream.write(response.getBytes());
    }

    return exchange.getResponseHeaders();
}
Enter a short text
___

Create a free account to access the full topic