-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.hpp
More file actions
44 lines (39 loc) · 1.22 KB
/
Copy pathrequest.hpp
File metadata and controls
44 lines (39 loc) · 1.22 KB
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
44
#pragma once
#include <string>
#include <map>
#include <vector>
using namespace std;
vector<string> split_header_lines(const string &request);
string read_until_double_crlf(int connfd);
void parse_request_line(const string &reqline,
string &method,
string &uri,
string &version);
void parse_header_field(const string &header,
string &name,
string &value);
void parse_request_header(int connfd,
string &method,
string &uri,
string &version,
map<string, string> &headers);
/*
Returns first position that is whitespace (space or tab)
starting from S[POS], or S.length().
*/
inline size_t first_ws(const string &s, size_t pos = 0) {
while (pos < s.length() &&
s[pos] != ' ' && s[pos] != '\t')
pos++;
return pos;
}
/*
Returns first position that is non-whitespace (not space or tab)
starting from S[POS], or S.length().
*/
inline size_t first_nonws(const string &s, size_t pos = 0) {
while (pos < s.length() &&
(s[pos] == ' ' || s[pos] == '\t'))
pos++;
return pos;
}