eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.61k stars 751 forks source link

Additional headers in config for HttpClient #181

Open moonshadow565 opened 6 years ago

moonshadow565 commented 6 years ago

Would like something like WsClient's config.header for HttpClient that sets additional headers to be sent when connection is (re)opened :)

eidheim commented 6 years ago

Thank you, but do you have an example use case for this so I can understand the importance of such a feature?

moonshadow565 commented 6 years ago

I would use it with authorization header. Currently i generate bunch of methods (roughly 2000) that take custom POD struct. The struct has authorization header string saved as well as HttpClient class. In generated methods i have to pass that header to each and every request. I can't relay on the connection not being closed (keep-alive?) since there are both synch(prefered) and asynch methods being generated. So just to be safe from such cases i pass the auth header to each and every request :)

That being said if there was such option it would make Simple-Web-Server more similar to Simple-WebSocket-Server.