-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHeaders.h
43 lines (31 loc) · 1.01 KB
/
Headers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <unordered_map>
#include "StringUtils.h"
namespace shitty {
using Header = std::pair<const std::string, std::string>;
extern const Header no_header;
class Headers {
public:
Headers() = default;
Headers(std::initializer_list<Header> headers):
kv_(headers)
{}
Headers(std::initializer_list<std::string> headers);
Headers& operator+=(const Headers&);
Headers& operator+=(Headers&&);
void set(const std::string& name, const std::string& value);
void add(const std::string& name, const std::string& value);
void remove(const std::string& name);
const Header& get(const std::string& name) const;
//private:
std::unordered_multimap<
std::string,
std::string,
ascii::CaseInsensitiveHash,
ascii::CaseInsensitiveEqual
> kv_;
};
// Set Date header and set Server header if not already set.
void setStandardHeaders(Headers& headers);
void setContentLength(Headers& headers, size_t content_length);
} // namespace shitty