0

I've been bashing my head for a few hours now. I finally was able to pass the server1 check50 last night, but the server2 check50 is killing me.

Source: server.c:

:) 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 \ expected output, not an exit code of 0 :( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, but not "X-Powered-By: PHP/5.5.7\r\nContent-type..." :) Requesting /test redirects to /test/ :( Requesting /test/ outputs /test/index.html :( Requesting directory containing index.php outputs index.php \ expected output, but not "HTTP/1.1 200 OK\r\nContent-Type: text/h..." :) Requesting two files in a row (cat.html then cat.jpg) succeeds Though I accept that my php files aren't passing the variables into the template, I'm not sure what is up with the /test/ folder. I tried it on my machine and /test does redirect to /test/ and /test/ output /test/index.html

Thank you in Advance,

Susanne :)

EDIT: Thanks to @user3781458 , the only remaining :( s are: :( Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0 :( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, but not "X-Powered-By: PHP/5.5.3\r\nContent-type..."

The source code link above has been updated :)

1 Answer 1

1

about your /test problem, you forgot to check if the path already has a '/' at the end, and add it if it's not the case.

5
  • I would update my parse function for that? May 22, 2016 at 20:39
  • no, the indexes function, you need to first check if the path is ending with '/', if it is you just concatenate your index.php and index.html to the path and check if they exists, if not, you concatenate /index.php and /index.html May 22, 2016 at 20:41
  • Thanks so much! I got that done. Now on to deal with the PHP variable passing.. Updating the status and code link now May 22, 2016 at 20:58
  • I'de love to help you with that, but your parse function isn't well documented, and isn't very readable. But if i have to guess, your query must be false, just try to find what's wrong with it. Also, try to null terminate strings that you copy using strncmp, because unless the null char is withing the range you're copying, your destination string won't be correctly null terminated. May 22, 2016 at 21:09
  • Perfect! It was a bad parse function. Fixed and good for check50! May 22, 2016 at 21:20

You must log in to answer this question.

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