Within the Build Your Own HTTP Server Challenge, I’m stuck on the “Read header” tests and noticed something interesting. When I run the tests in GitLab, I pass the first test for the User Agent, but then fail the second stage for some reason I can’t figure out. The second test is literally the previous challenge for the echo endpoint, so I don’t know why I’m getting the error:
"Failed to read response:
Received: "" (no content received)
^ error
Error: Expected: HTTP-version, Received: ""
Test failed"
Then, I noticed that if I try to run the tests via codecrafters cli, my code fails the User Agent test. Also, when I take the test curl commands from the terminal and run them locally, everything works and my code provides the right answer.
Does anyone have any suggestions for why my code can pass the user agent test on GitLab, but not on codecrafters cli? Or why they would fail the test runners but work locally? Is there something going on with the cmake files or environmental variables?
Hey @andy1li thanks for your help on this! Hope I didn’t take up too much of your Sunday. Quick clarification: I looped through the client’s GET request in the first loop to break it into pieces along the carriage returns, then I looped through it again in the second loop to find the values and save them in the hardcoded order that I wanted. So, I don’t think it was the ordering, per say. My program could handle the slightly different orderings of the echo endpoint vs the user agent endpoint.
That said, your comments did point me to the fact that I was trying to accept the body of the client’s GET request and save a pointer to it, which was royally screwing everything up. I think the body of the client’s GET request was basically nonsense, so trying to save a pointer to it was a disaster. At least I think that’s what happened, then again, I barely know what I’m doing.
Either way, I couldn’t have passed these tests without you. Thanks!