0

I'm almost there, I already solved a lot of problem, and I'm hoping that's the last one...

that is the result of check50

:) server.c exists
:) server compiles
:) Requesting cat.jpg returns 200, image/jpeg, and correct image
:) Requesting cat.html returns 200, text/html, and correct file
:) Requesting cat2.HTML returns 200, text/html, and correct file
:) Requesting cat3.HtMl returns 200, text/html, and correct file
:) Requesting cat.gif returns 200, image/gif, and correct file
:) Requesting favicon.ico returns 200, image/x-icon, and correct file
:) Requesting test.css returns 200, text/css, and correct file
:) Requesting test.js returns 200, text/javascript, and correct file
:) Requesting hello.php returns 200, text/html, and correct output
:) Requesting hello.php? returns 200, text/html, and correct output
:) Requesting hello.php?name=Alice returns 200, text/html, and correct output
:) Requesting /test redirects to /test/
:( Requesting /test/ outputs /test/index.html
:) Requesting directory containing index.php outputs index.php
:) Requesting two files in a row (cat.html then cat.jpg) succeeds

The only problem is with /test/ but if I run it with debug50 it works correctly:

GET /test/ HTTP/1.1
Data: <!DOCTYPE html>

<html>
<head>
    <title>RickRoll'D</title>
</head>
<body>
    <iframe width="420" height="315" src="https://www.youtube.com/embed/oHg5SJYRHA0?autoplay=1&iv_load_policy=3" frameborder="0" allowfullscreen></iframe>
</body>

Length: 271
HTTP/1.1 200 OK

Another problem is that if I test server.c directly on the browser (and not with curl, that works!) I always get 405 method not allowed

Thanks in advance for any suggestions!

2

Since :( Requesting /test/ outputs /test/index.html is the only index test that fails and index.html is one byte longer than index.php you might first verify that the variable you declare and allocate for your return value is allocated properly.

All things being equal, the only 405 in server is the one you added to parse. The difference between a curl request and a browser request is favicon.ico. You may want to use valgrind or debug50 or gdb to help you debug it. Although it seems odd that there would be a problem in parse, since check50 passes everything else. Start with debugging the indexes problem.

  • Thanks! I added +1 to the malloc of the return variables and now the program pass the check50! Still getting the 405 though... that's really weird.. – Margherita Bonaldi Sep 24 '16 at 16:00
  • It's not weird. It's a bug :) "weird" is often caused by a memory leak. valgrind is the go-to tool. This command line valgrind -v --leak-check=full --show-leak-kinds=all --track-origins=yes gives lots of good feedback. Code on! – DinoCoderSaurus Sep 24 '16 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .