send http headers in original order

This commit is contained in:
orignal 2017-02-04 22:39:54 -05:00
parent 7ae38a71cc
commit 66f3bd186f
6 changed files with 113 additions and 66 deletions

15
HTTP.h
View file

@ -11,6 +11,7 @@
#include <cstring>
#include <map>
#include <list>
#include <sstream>
#include <string>
#include <vector>
@ -54,7 +55,8 @@ namespace http {
std::string to_string ();
};
struct HTTPMsg {
struct HTTPMsg
{
std::map<std::string, std::string> headers;
void add_header(const char *name, std::string & value, bool replace = false);
@ -65,7 +67,9 @@ namespace http {
long int content_length();
};
struct HTTPReq : HTTPMsg {
struct HTTPReq
{
std::list<std::pair<std::string, std::string> > headers;
std::string version;
std::string method;
std::string uri;
@ -82,9 +86,12 @@ namespace http {
/** @brief Serialize HTTP request to string */
std::string to_string();
void write(std::ostream & o);
void write(std::ostream & o);
void AddHeader (const std::string& name, const std::string& value);
void UpdateHeader (const std::string& name, const std::string& value);
void RemoveHeader (const std::string& name);
std::string GetHeader (const std::string& name) const;
};
struct HTTPRes : HTTPMsg {