0xOnyx / 42_webserv

Webserv light in c++ 98 with epoll
MIT License
0 stars 0 forks source link

Create class for HTTP request #6

Open 0xOnyx opened 1 year ago

0xOnyx commented 1 year ago

make a class that allows you to generate HTTP requests and that returns all of these in a std::string

LeRoiErrant commented 1 year ago

Accordingly to what we discussed before, by HTTP request you mean HTTP response I think ?

0xOnyx commented 1 year ago

Yes, we should create a template class that would allow creating requests according to the HTTP1.1 standard. Here's what it should take as parameters for the constructor:

The request status, e.g., 200, 404, etc., as an integer The length of the body as a size_t The type of the body as a std::string If the length is greater than 0, then take the body as a std::string. Then, you should return a correctly formatted std::string that I can send when the socket is available for writing, as follows:

HTTP/1.1 200 OK Content-Type: text/html

<!DOCTYPE html>

Hello World

Hello World!