123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #pragma once
- #include <map>
- #include <vector>
- #include <string>
- #if (defined(__clang__) && defined(_LIBCPP_VERSION)) || (__cplusplus >= 201103L)
- #include <memory>
- #else
- #include <tr1/memory>
- #endif
- #include <curl/curl.h>
- #ifdef USE_LUA
- #include <lua.hpp>
- #endif
- class BBS2chProxyHttpHeaderEntry {
- private:
- std::string _name;
- std::vector<std::string> _values;
- public:
- BBS2chProxyHttpHeaderEntry(const std::string &name, const std::string &value)
- {
- _name = name;
- _values.push_back(value);
- };
- const std::string& getName(void);
- std::string getLowercasedName(void);
- std::string getValue(void);
- std::string getFull(void);
- std::vector<std::string>& getValueList(void);
- void add(const std::string &value);
- void set(const std::string &value);
- bool has(const std::string &value);
- bool contains(const std::string &value);
- };
- #if (defined(__clang__) && defined(_LIBCPP_VERSION)) || (__cplusplus >= 201103L)
- typedef std::shared_ptr<BBS2chProxyHttpHeaderEntry> PBBS2chProxyHttpHeaderEntry;
- #else
- typedef std::tr1::shared_ptr<BBS2chProxyHttpHeaderEntry> PBBS2chProxyHttpHeaderEntry;
- #endif
- class BBS2chProxyHttpHeaders {
- private:
- std::map<std::string, PBBS2chProxyHttpHeaderEntry> _headers;
- public:
- std::string get(const std::string &name);
- bool has(const std::string &name);
- bool hasNameAndValue(const std::string &name, const std::string &value);
- void add(const std::string &name, const std::string &value);
- void add(const char *field);
- void add(const char *field, size_t length);
- void set(const std::string &name, const std::string &value);
- void remove(const std::string &name);
- void clear(void);
- curl_slist* appendToCurlSlist(curl_slist *list);
- curl_slist* appendToCurlSlist(curl_slist *list, const std::string &name);
- std::map<std::string, PBBS2chProxyHttpHeaderEntry>& getMap(void);
- static PBBS2chProxyHttpHeaderEntry parse(const char *field, size_t length);
- #ifdef USE_LUA
- static void getObjectMetatableForLua(lua_State *l);
- static void getClassDefinitionForLua(lua_State *l);
- void getUserdataForLua(lua_State *l);
- #endif
- };
|