Http-server:extracturl

I’m stuck on Extract Url path stage in http server

I’m unable to debug locally, even i set to true in yaml file.

[tester::#IH0] Running tests for Stage #IH0 (Extract URL path)
remote: [tester::#IH0] Running program
remote: [tester::#IH0] $ ./your_program.sh
remote: [your_program] Logs from your program will appear here!
remote: [tester::#IH0] Connected to localhost port 4221
remote: [tester::#IH0] $ curl -v http://localhost:4221/blueberry
remote: [tester::#IH0] > GET /blueberry HTTP/1.1
remote: [tester::#IH0] > Host: localhost:4221
remote: [tester::#IH0] >
remote: [tester::#IH0] Sent bytes: "GET /blueberry HTTP/1.1\r\nHost: localhost:4221\r\n\r\n"
remote: [your_program] GET /blueberry HTTP/1.1
remote: [your_program] HTTP/1.1 404 Not Found
remote: [your_program]
remote: [your_program]
remote: [tester::#IH0] Received bytes: "HTTP/1.1 200 OK\r\n\r\n"
remote: [tester::#IH0] < HTTP/1.1 200 OK
remote: [tester::#IH0] <
remote: [tester::#IH0] Expected status code 404, got 200
remote: [tester::#IH0] Test failed
remote: [tester::#IH0] Terminating program
remote: [tester::#IH0] Program terminated successfully

And here’s a snippet of my code:

 BufferedReader bufferedReader = new BufferedReader(
                    new InputStreamReader(clientSocket.getInputStream()));
            String requestString = bufferedReader.readLine();
            String responseString;

            System.out.println(requestString);

            if (requestString != null && requestString.split(" ")[1].equals("/")) {

                responseString = "HTTP/1.1 200 OK\r\n\r\n";
            } else {
                responseString = "HTTP/1.1 404 Not Found\r\n\r\n";
            }

            System.out.println(responseString);
        } catch (IOException e) {
            System.out.println("IOException: " + e.

Hey @ravivarmalearner, the issue was caused by an extra "HTTP/1.1 200 OK\r\n\r\n" here:

Let me know if you’d like further clarification!

1 Like

Thank you. It works

1 Like