-
Notifications
You must be signed in to change notification settings - Fork 4
/
HttpResponse.h
64 lines (45 loc) · 1.4 KB
/
HttpResponse.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/***************************************************/
/* This class is used to response client's request */
/* Author:zhcuhao 2015-11-3 */
/***************************************************/
/* HTTPResponse.h */
#ifndef _HTTP_RESPONSE_H_
#define _HTTP_RESPONSE_H_
#include<string>
#include<vector>
#include<fstream>
#include"Http.h"
using namespace std;
class HttpResponse{
public:
HttpResponse();
~HttpResponse();
void printResponse(void );
void addData(const char *, const int&);
int setProtocol(Protocol );
Protocol getProtocol(void );
int setStatusCode(size_t );
size_t getStatusCode(void );
int setReasonPhrase(void );
string getReasonPhrase(void );
int setHTTPHeader(string headerName, string headerContent);
string getHTTPHeader(string headerName);
int setHTTPHeaderVector(vector<pair<string, string> >* const );
vector<pair<string, string> >* getHTTPHeaderVector(void );
int setResponseBody(const string* );
string* getResponseBodyPtr(void );
int prepareResponse(void );
int parseResponse(void );
size_t getResponseSize(void );
string* getResponseDataPtr(void );
int copyToFile(ofstream& );
int copyFromFile(ifstream&, int);
private:
Protocol m_protocol;
size_t m_statusCode;
string m_reasonPhrase;
vector<pair<string, string> > m_httpHeaders;
string m_responseBody;
string m_data;
};
#endif /* _HTTP_RESPONSE_H_ */