AP6 Passing and EJ5 failing

I have hardcoded the directory flag as a string instead of taking it as an input and it passes ap6 but somehow fails the EJ5 despite no change to that code.

I saw similar post but in that solution suggested seemed different than my issue.

[tester::#AP6] Received response with 404 status code

[tester::#AP6] Test passed.

[tester::#AP6] Terminating program

[tester::#AP6] Program terminated successfully

[tester::#EJ5] Running tests for Stage #EJ5 (Concurrent connections)

[tester::#EJ5] Running program

[tester::#EJ5] $ ./your_server.sh

[tester::#EJ5] Creating 2 parallel connections

[tester::#EJ5] Creating connection 1

[tester::#EJ5] Creating connection 2

[tester::#EJ5] Sending first set of requests

[tester::#EJ5] client-2: $ curl -v http://localhost:4221/

[tester::#EJ5] client-2: > GET / HTTP/1.1

[tester::#EJ5] client-2: > Host: localhost:4221

[tester::#EJ5] client-2: >

[tester::#EJ5] client-2: Sent bytes: "GET / HTTP/1.1\r\nHost: localhost:4221\r\n\r\n"

[your_program] accepted new connection

[tester::#EJ5] Failed to read response:

[tester::#EJ5] Received: "" (no content received)

[tester::#EJ5] ^ error

[tester::#EJ5] Error: Expected: HTTP-version, Received: ""

[tester::#EJ5] Test failed

[tester::#EJ5] Terminating program

[tester::#EJ5] Program terminated successfully

this is the logs of test.

this is my code portion for ap6

 String filename = path.split("/")[2];
                String filePathStr  = "/tmp/" + filename;
                System.out.println(filePathStr);
                Path filePath = Paths.get("/tmp/data/codecrafters.io/http-server-tester/",filename);
                if(Files.exists(filePath)){
                String fileText = Files.readString(filePath);
                writer.write("HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: " + fileText.length() + "\r\n\r\n" + fileText);
                } else {
                writer.write("HTTP/1.1 404 Not Found\r\n\r\n");
                }

@RammohanSharmaGit something must’ve changed in the code that handles the earlier stage, maybe there’s some kind of global function or something that changed? Could you paste the full code here?

Closing this thread due to inactivity. If you still need assistance, feel free to start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.