Skip to content

Commit b814134

Browse files
committed
Folder restructure. Missing changes from the last commit
1 parent b5739d2 commit b814134

20 files changed

+116
-331
lines changed

Makefile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Makefile for httpserver
22
# (C) Ramsey Kant 2011-2012
33

4-
CC = g++
5-
OBJS = ByteBuffer.o Client.o HTTPMessage.o HTTPRequest.o HTTPResponse.o HTTPServer.o main.o Resource.o ResourceManager.o
4+
CC = clang++
5+
OBJS = ByteBuffer.o Client.o HTTPMessage.o HTTPRequest.o HTTPResponse.o HTTPServer.o main.o Resource.o ResourceHost.o
66
# Debug Flags
77
DEBUGFLAGS = -g -O0 -Wall
88
# Production Flags
@@ -12,37 +12,37 @@ FLAGS = -Iinclude/ $(DEBUGFLAGS)
1212
# LINK = -lpthread -lboost_thread-mt
1313

1414
all: $(OBJS)
15-
$(CC) $(FLAGS) *.o -o bin/httpserver
15+
$(CC) $(FLAGS) src/*.o -o bin/httpserver
1616

17-
ByteBuffer.o: ByteBuffer.cpp
18-
$(CC) $(FLAGS) -c ByteBuffer.cpp -o $@
17+
ByteBuffer.o: src/ByteBuffer.cpp
18+
$(CC) $(FLAGS) -c src/ByteBuffer.cpp -o src/$@
1919

20-
Client.o: Client.cpp
21-
$(CC) $(FLAGS) -c Client.cpp -o $@
20+
Client.o: src/Client.cpp
21+
$(CC) $(FLAGS) -c src/Client.cpp -o src/$@
2222

23-
HTTPMessage.o: HTTPMessage.cpp
24-
$(CC) $(FLAGS) -c HTTPMessage.cpp -o $@
23+
HTTPMessage.o: src/HTTPMessage.cpp
24+
$(CC) $(FLAGS) -c src/HTTPMessage.cpp -o src/$@
2525

26-
HTTPRequest.o: HTTPRequest.cpp
27-
$(CC) $(FLAGS) -c HTTPRequest.cpp -o $@
26+
HTTPRequest.o: src/HTTPRequest.cpp
27+
$(CC) $(FLAGS) -c src/HTTPRequest.cpp -o src/$@
2828

29-
HTTPResponse.o: HTTPResponse.cpp
30-
$(CC) $(FLAGS) -c HTTPResponse.cpp -o $@
29+
HTTPResponse.o: src/HTTPResponse.cpp
30+
$(CC) $(FLAGS) -c src/HTTPResponse.cpp -o src/$@
3131

32-
HTTPServer.o: HTTPServer.cpp
33-
$(CC) $(FLAGS) -c HTTPServer.cpp -o $@
32+
HTTPServer.o: src/HTTPServer.cpp
33+
$(CC) $(FLAGS) -c src/HTTPServer.cpp -o src/$@
3434

35-
main.o: main.cpp
36-
$(CC) $(FLAGS) -c main.cpp -o $@
35+
main.o: src/main.cpp
36+
$(CC) $(FLAGS) -c src/main.cpp -o src/$@
3737

38-
Resource.o: Resource.cpp
39-
$(CC) $(FLAGS) -c Resource.cpp -o $@
38+
Resource.o: src/Resource.cpp
39+
$(CC) $(FLAGS) -c src/Resource.cpp -o src/$@
4040

41-
ResourceManager.o: ResourceManager.cpp
42-
$(CC) $(FLAGS) -c ResourceManager.cpp -o $@
41+
ResourceHost.o: src/ResourceHost.cpp
42+
$(CC) $(FLAGS) -c src/ResourceHost.cpp -o src/$@
4343

4444
.PHONY: clean
4545
clean:
4646
rm -f bin/httpserver
47-
rm -f *.o
47+
rm -f src/*.o
4848

ResourceManager.cpp

Lines changed: 0 additions & 169 deletions
This file was deleted.

ResourceManager.h

Lines changed: 0 additions & 62 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

HTTPMessage.cpp renamed to src/HTTPMessage.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ HTTPMessage::HTTPMessage(byte* pData, unsigned int len) : ByteBuffer(pData, len)
3232
}
3333

3434
HTTPMessage::~HTTPMessage() {
35-
if(createRetData != NULL) {
36-
delete createRetData;
37-
createRetData = NULL;
38-
}
39-
4035
headers->clear();
4136
delete headers;
4237
}
@@ -48,9 +43,6 @@ void HTTPMessage::init() {
4843
dataLen = 0;
4944

5045
version = HTTP_VERSION; // By default, all create() will indicate the version is whatever HTTP_VERSION is
51-
52-
createRetData = NULL;
53-
createCached = false;
5446

5547
headers = new map<string, string>();
5648
}

HTTPMessage.h renamed to src/HTTPMessage.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ class HTTPMessage : public ByteBuffer {
8787
// Message Body Data (Resource in the case of a response, extra parameters in the case of a request)
8888
byte* data;
8989
unsigned int dataLen;
90-
91-
// Caching variables
92-
bool createCached;
93-
byte* createRetData;
9490

9591
protected:
9692
virtual void init();
@@ -101,8 +97,8 @@ class HTTPMessage : public ByteBuffer {
10197
HTTPMessage(byte *pData, unsigned int len);
10298
virtual ~HTTPMessage();
10399

104-
virtual byte* create(bool freshCreate=false) {return NULL;};
105-
virtual bool parse() {return false;};
100+
virtual byte* create() = 0;
101+
virtual bool parse() = 0;
106102

107103
// Create helpers
108104
void putLine(string str = "", bool crlf_end=true);

HTTPRequest.cpp renamed to src/HTTPRequest.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,11 @@ string HTTPRequest::methodIntToStr(unsigned int mid) {
8080
* Create
8181
* Create and return a byte array of an HTTP request, built from the variables of this HTTPRequest
8282
*
83-
* @param freshCreate If true, force a rebuild of the packet even if there's a previously cached version
8483
* @return Byte array of this HTTPRequest to be sent over the wire
8584
*/
86-
byte* HTTPRequest::create(bool freshCreate) {
87-
// Clear the bytebuffer in the event this isn't the first call of create(), or if a fresh create is desired
88-
if(!createCached || freshCreate) {
89-
clear();
90-
} else { // Otherwise, return the already created data
91-
return createRetData;
92-
}
93-
94-
if(createRetData != NULL) {
95-
delete createRetData;
96-
createRetData = NULL;
97-
}
85+
byte* HTTPRequest::create() {
86+
// Clear the bytebuffer in the event this isn't the first call of create()
87+
clear();
9888

9989
// Insert the initial line: <method> <path> <version>\r\n
10090
string mstr = "";
@@ -114,12 +104,9 @@ byte* HTTPRequest::create(bool freshCreate) {
114104
}
115105

116106
// Allocate space for the returned byte array and return it
117-
createRetData = new byte[size()];
107+
byte* createRetData = new byte[size()];
118108
setReadPos(0);
119109
getBytes(createRetData, size());
120-
121-
// createCached should now be true, because a create was successfully performed.
122-
createCached = true;
123110

124111
return createRetData;
125112
}

0 commit comments

Comments
 (0)