-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpRequest.h
39 lines (35 loc) · 857 Bytes
/
HttpRequest.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
/*
* HttpRequest.h
*
* Created on: May 28, 2020
* Author: voukatas
*/
#pragma once
#include <sstream>
#include <map>
class HttpRequest
{
private:
int clientSocket;
std::istringstream request;
std::string method_name;
std::string path;
std::string protocol;
void parseReqFirstLine(std::string& line);
void parseReqFields(std::string& line);
std::map<std::string, std::string> fieldMap;
public:
explicit HttpRequest(int clientSocket);
virtual ~HttpRequest() = default;
int readData();
void parseReq();
std::string getRequest();
std::string getMethodName();
std::string& getPath();
std::string getProtocol();
int isReqValid();
static bool is_path_file(std::string path);
//for testing purposes, maybe include a mocking framework later
void setRequest(std::string req);
std::map<std::string, std::string>& getFieldMap();
};