Skip to content

Build a Web Server: Step 20 rejects valid curl command due to raw terminal input #49

Description

@majestic-owl448

Step 20 of Build a Web Server can reject the instructed command even when the server responds correctly.

Reproduction

  1. Complete Step 19 so that the server calls response.end(request.url).

  2. Restart the server with node server.js.

  3. In another terminal, run:

    curl http://localhost:3001/hello
  4. Click Run Tests.

Actual behavior

The test requires the exact substring curl http://localhost:3001/hello in __helpers.getTemp(). getTemp() reads .logs/.temp.log, which records raw terminal input. Terminal control sequences can split the command, so the substring assertion fails even though the command was run and the server returns a response.

Expected behavior

The instructed command should pass regardless of terminal escape sequences.

Proposed fix

Use __helpers.getLastCommand() and __helpers.parseCli() to verify that the command is curl and that its arguments include http://localhost:3001/hello. Step 18 already uses this approach for a similar curl assertion.

This is a remaining instance of the raw-terminal-log failure reported in #12, which was closed by commit 27aae2a.

Affected source:

## 20
### --description--
Restart your server, and make a request to `http://localhost:3001/hello`. You no longer need to add a timeout to your `curl` command, because your sever is responding with something.
### --tests--
You should restart the server, and make a request to it.
```js
const temp = await __helpers.getTemp();
assert.include(temp, "curl http://localhost:3001/hello");
```

Forum report: https://forum.freecodecamp.org/t/build-a-web-server-build-a-web-server/799172

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions