I’m stuck on Stage #IA4.
Here are my logs:
Failed to read response:
remote: [tester::#IA4] Received: "" (no content received)
remote: [tester::#IA4] ^ error
remote: [tester::#IA4] Error: Expected: HTTP-version, Received: ""
remote: [tester::#IA4] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
And here’s a snippet of my code:
public static void main(String[] args) {
// You can use print statements as follows for debugging, they'll be visible
// when running tests.
System.out.println("Logs from your program will appear here!");
ServerSocket serverSocket = null;
Socket clientSocket = null;
try {
serverSocket = new ServerSocket(4221);
// Since the tester restarts your program quite often, setting
// SO_REUSEADDR ensures that we don't run into 'Address already in use'
serverSocket.setReuseAddress(true);
clientSocket = serverSocket.accept(); // Wait for connection from client.
System.out.println("accepted new connection");
String response = "HTTP/1.1 200 OK\r\n\r\n";
clientSocket.getOutputStream().write(response.getBytes());
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
}
}```