Skip to content

Commit 558ae76

Browse files
author
Sebastiano Merlino
committed
Moved dependencies from headers to cpp files
1 parent 888350d commit 558ae76

File tree

4 files changed

+80
-72
lines changed

4 files changed

+80
-72
lines changed

src/HttpRequest.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,53 @@ bool HttpRequest::checkDigestAuth(const std::string& realm, const std::string& p
4848
return true;
4949
}
5050

51+
const std::vector<std::pair<std::string, std::string> > HttpRequest::getHeaders() const
52+
{
53+
std::vector<std::pair<std::string, std::string> > toRet;
54+
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
55+
for(it = headers.begin(); it != headers.end(); it++)
56+
#ifdef USE_CPP_ZEROX
57+
toRet.push_back(std::make_pair((*it).first,(*it).second));
58+
#else
59+
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
60+
#endif
61+
return toRet;
62+
}
63+
const std::vector<std::pair<std::string, std::string> > HttpRequest::getFooters() const
64+
{
65+
std::vector<std::pair<std::string, std::string> > toRet;
66+
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
67+
for(it = footers.begin(); it != footers.end(); it++)
68+
#ifdef USE_CPP_ZEROX
69+
toRet.push_back(std::make_pair((*it).first,(*it).second));
70+
#else
71+
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
72+
#endif
73+
return toRet;
74+
}
75+
const std::vector<std::pair<std::string, std::string> > HttpRequest::getCookies() const
76+
{
77+
std::vector<std::pair<std::string, std::string> > toRet;
78+
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
79+
for(it = cookies.begin(); it != cookies.end(); it++)
80+
#ifdef USE_CPP_ZEROX
81+
toRet.push_back(std::make_pair((*it).first,(*it).second));
82+
#else
83+
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
84+
#endif
85+
return toRet;
86+
}
87+
const std::vector<std::pair<std::string, std::string> > HttpRequest::getArgs() const
88+
{
89+
std::vector<std::pair<std::string, std::string> > toRet;
90+
std::map<std::string, std::string, ArgComparator>::const_iterator it;
91+
for(it = args.begin(); it != args.end(); it++)
92+
#ifdef USE_CPP_ZEROX
93+
toRet.push_back(std::make_pair((*it).first,(*it).second));
94+
#else
95+
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
96+
#endif
97+
return toRet;
98+
}
99+
51100
};

src/HttpResponse.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ using namespace std;
2828

2929
namespace httpserver
3030
{
31+
32+
const std::vector<std::pair<std::string, std::string> > HttpResponse::getHeaders()
33+
{
34+
std::vector<std::pair<std::string, std::string> > toRet;
35+
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
36+
for(it = headers.begin(); it != headers.end(); it++)
37+
#ifdef USE_CPP_ZEROX
38+
toRet.push_back(std::make_pair((*it).first,(*it).second));
39+
#else
40+
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
41+
#endif
42+
return toRet;
43+
}
44+
const std::vector<std::pair<std::string, std::string> > HttpResponse::getFooters()
45+
{
46+
std::vector<std::pair<std::string, std::string> > toRet;
47+
std::map<std::string, std::string, ArgComparator>::const_iterator it;
48+
for(it = footers.begin(); it != footers.end(); it++)
49+
#ifdef USE_CPP_ZEROX
50+
toRet.push_back(std::make_pair((*it).first,(*it).second));
51+
#else
52+
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
53+
#endif
54+
return toRet;
55+
}
3156
//RESPONSE
3257
HttpFileResponse::HttpFileResponse
3358
(

src/httpserver/HttpRequest.hpp

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -134,66 +134,22 @@ class HttpRequest
134134
* Method used to get all headers passed with the request.
135135
* @return a vector<pair<string,string> > containing all headers.
136136
**/
137-
const std::vector<std::pair<std::string, std::string> > getHeaders() const
138-
{
139-
std::vector<std::pair<std::string, std::string> > toRet;
140-
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
141-
for(it = headers.begin(); it != headers.end(); it++)
142-
#ifdef USE_CPP_ZEROX
143-
toRet.push_back(std::make_pair((*it).first,(*it).second));
144-
#else
145-
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
146-
#endif
147-
return toRet;
148-
}
137+
const std::vector<std::pair<std::string, std::string> > getHeaders() const;
149138
/**
150139
* Method used to get all footers passed with the request.
151140
* @return a vector<pair<string,string> > containing all footers.
152141
**/
153-
const std::vector<std::pair<std::string, std::string> > getFooters() const
154-
{
155-
std::vector<std::pair<std::string, std::string> > toRet;
156-
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
157-
for(it = footers.begin(); it != footers.end(); it++)
158-
#ifdef USE_CPP_ZEROX
159-
toRet.push_back(std::make_pair((*it).first,(*it).second));
160-
#else
161-
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
162-
#endif
163-
return toRet;
164-
}
142+
const std::vector<std::pair<std::string, std::string> > getFooters() const;
165143
/**
166144
* Method used to get all cookies passed with the request.
167145
* @return a vector<pair<string, string> > containing all cookies.
168146
**/
169-
const std::vector<std::pair<std::string, std::string> > getCookies() const
170-
{
171-
std::vector<std::pair<std::string, std::string> > toRet;
172-
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
173-
for(it = cookies.begin(); it != cookies.end(); it++)
174-
#ifdef USE_CPP_ZEROX
175-
toRet.push_back(std::make_pair((*it).first,(*it).second));
176-
#else
177-
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
178-
#endif
179-
return toRet;
180-
}
147+
const std::vector<std::pair<std::string, std::string> > getCookies() const;
181148
/**
182149
* Method used to get all parameters passed with the request. Usually parameters are passed with DELETE or GET methods.
183150
* @return a map<string,string> containing all parameters.
184151
**/
185-
const std::vector<std::pair<std::string, std::string> > getArgs() const
186-
{
187-
std::vector<std::pair<std::string, std::string> > toRet;
188-
std::map<std::string, std::string, ArgComparator>::const_iterator it;
189-
for(it = args.begin(); it != args.end(); it++)
190-
#ifdef USE_CPP_ZEROX
191-
toRet.push_back(std::make_pair((*it).first,(*it).second));
192-
#else
193-
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
194-
#endif
195-
return toRet;
196-
}
152+
const std::vector<std::pair<std::string, std::string> > getArgs() const;
197153
/**
198154
* Method used to get a specific header passed with the request.
199155
* @param key the specific header to get the value from

src/httpserver/HttpResponse.hpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -172,34 +172,12 @@ class HttpResponse
172172
* Method used to get all headers passed with the request.
173173
* @return a map<string,string> containing all headers.
174174
**/
175-
const std::vector<std::pair<std::string, std::string> > getHeaders()
176-
{
177-
std::vector<std::pair<std::string, std::string> > toRet;
178-
std::map<std::string, std::string, HeaderComparator>::const_iterator it;
179-
for(it = headers.begin(); it != headers.end(); it++)
180-
#ifdef USE_CPP_ZEROX
181-
toRet.push_back(std::make_pair((*it).first,(*it).second));
182-
#else
183-
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
184-
#endif
185-
return toRet;
186-
}
175+
const std::vector<std::pair<std::string, std::string> > getHeaders();
187176
/**
188177
* Method used to get all footers passed with the request.
189178
* @return a map<string,string> containing all footers.
190179
**/
191-
const std::vector<std::pair<std::string, std::string> > getFooters()
192-
{
193-
std::vector<std::pair<std::string, std::string> > toRet;
194-
std::map<std::string, std::string, ArgComparator>::const_iterator it;
195-
for(it = footers.begin(); it != footers.end(); it++)
196-
#ifdef USE_CPP_ZEROX
197-
toRet.push_back(std::make_pair((*it).first,(*it).second));
198-
#else
199-
toRet.push_back(std::make_pair<std::string, std::string>((*it).first,(*it).second));
200-
#endif
201-
return toRet;
202-
}
180+
const std::vector<std::pair<std::string, std::string> > getFooters();
203181
/**
204182
* Method used to set all headers of the response.
205183
* @param headers The headers key-value map to set for the response.

0 commit comments

Comments
 (0)