20

I am currently in a bit of a (well-deserved) lull at work, both of my projects are finishing up/ finished, so tomorrow should be pretty light, as the latter half of today was.

And I have really gotten interested in the HTTP protocol. It's so interesting learning how it all works under the hood.

So I think I'm going to be researching/ messing around with creating a cpp project that essentially implements cURL from the ground up, creating sockets, reading from them, parsing the HTTP requests... all that. I don't expect to actually get it done, but it should be an immense learning experience. I have a clear goal: implement this function:

std::string get(const std::string&);

Once I'm able to just GET as simple as that, I know I have achieved my goal!

Comments
  • 3
    I think you may need a bit more parameters :) like headers. At least info for Authorization header

    edit: unless you make passing auth data as a separate method and store it inside the object.. But then it might be difficult to determine whether get() failed or whether it failed due to expired credentials.

    Unless you throw exceptions. But then exception handling will litter your nice and clean code 😁

    and then there is the request params. Sure you can concat them to a single string and append to url, but I doubt it will not litter your code as well [before the get call]. Pasing a const static char* also is questionable as rest apis use dynamic urls to access resources. And params are somewhat of a dynamic thing as well.
  • 1
    When you have time, try to implement chunked encoding
  • 1
    @netikras It's going to be a sort of drill-down abstraction of overloaded methods. get will just reference a more generic request method with some predetermined request options
Add Comment