forked from ZCXL/HttpServer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHttpServer.h
44 lines (39 loc) · 992 Bytes
/
HttpServer.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
/**********************************************/
/* This class is used to get client's request */
/* ,process request,and response */
/* Author:zhuchao 2015-11-3 */
/**********************************************/
#ifndef _HTTP_SERVER_H_
#define _HTTP_SERVER_H_
#include <arpa/inet.h>
#include <sys/socket.h>
#include "HttpResponse.h"
#include "HttpRequest.h"
/* buffer size */
#define BUF_SIZE 512
class HttpServer{
public:
HttpServer();
HttpServer(int);
~HttpServer();
int run(void);
int setPort(size_t);
int initSocket(void);
int handleRequest(void);
int recvRequest(void);
int parseRequest(void);
int processRequest(void);
int prepareResponse(void);
int sendResponse(void);
private:
string getMimeType(string);
size_t svrPort;
int sockfd,newsockfd;
socklen_t cliLen;
struct sockaddr_in servAddr,cliAddr;
string m_url;
string m_mimeType;
HttpRequest* httpRequest;
HttpResponse* httpResponse;
};
#endif