Блог пользователя MaxWelll

Автор MaxWelll, история, 8 месяцев назад, По-английски

Some days ago I completed all stages of the CodeCrafters "Build your own HTTP server" challenge in C++. My code was made to pass each stage of the challenge, but I took some extra time to refactor it into something that I could use in the future.

Check out my code on GitHub and feel free to share your feedback!

These are some of the issues I know exist or questions and would like to address:

  • I have some issues with posting files:

    • posting images, for example, doesn't work. I dont get the same file as the one I posted
    • I also just noticed that when posting text files it doesn't write the end lines
  • My Dispatcher takes a std::function<HttpResponse(HttpRequest&, std::vector<std::string>)> and then uses it to get a HttpResponse. But in some cases, (by now just when the response is built with .stream) I'm taking a reference to a stream that is built inside the function, when the function end it goes out of scope. Any elegant workaround for this? In my case I just declared the stream outside of my dispatcher build, but that's just a hack.

  • The base code given for the socket connection seems like it uses a C-style API. Is there any C++ way of using sockets?

  • Проголосовать: нравится
  • +18
  • Проголосовать: не нравится