Skip to content

Commit fa32c21

Browse files
author
Sebastiano Merlino
committed
Avoid usage of 'using' in headers
1 parent 8d8e035 commit fa32c21

File tree

5 files changed

+41
-47
lines changed

5 files changed

+41
-47
lines changed

src/http_request.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,25 @@ bool http_request::check_digest_auth(
6262
return true;
6363
}
6464

65-
size_t http_request::get_headers(std::map<std::string, std::string, header_comparator>& result) const
65+
size_t http_request::get_headers(std::map<std::string, std::string, http::header_comparator>& result) const
6666
{
6767
result = this->headers;
6868
return result.size();
6969
}
7070

71-
size_t http_request::get_footers(std::map<std::string, std::string, header_comparator>& result) const
71+
size_t http_request::get_footers(std::map<std::string, std::string, http::header_comparator>& result) const
7272
{
7373
result = this->footers;
7474
return result.size();
7575
}
7676

77-
size_t http_request::get_cookies(std::map<std::string, std::string, header_comparator>& result) const
77+
size_t http_request::get_cookies(std::map<std::string, std::string, http::header_comparator>& result) const
7878
{
7979
result = this->cookies;
8080
return result.size();
8181
}
8282

83-
size_t http_request::get_args(std::map<std::string, std::string, arg_comparator>& result) const
83+
size_t http_request::get_args(std::map<std::string, std::string, http::arg_comparator>& result) const
8484
{
8585
result = this->args;
8686
return result.size();
@@ -101,6 +101,6 @@ std::ostream &operator<< (std::ostream &os, const http_request &r)
101101

102102
return os;
103103
}
104-
104+
105105

106106
}

src/http_response.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ http_response::~http_response()
7272
webserver::unlock_cache_entry(ce);
7373
}
7474

75-
size_t http_response::get_headers(std::map<std::string, std::string, header_comparator>& result) const
75+
size_t http_response::get_headers(std::map<std::string, std::string, http::header_comparator>& result) const
7676
{
7777
result = this->headers;
7878
return result.size();
7979
}
8080

81-
size_t http_response::get_footers(std::map<std::string, std::string, header_comparator>& result) const
81+
size_t http_response::get_footers(std::map<std::string, std::string, http::header_comparator>& result) const
8282
{
8383
result = this->footers;
8484
return result.size();
8585
}
8686

87-
size_t http_response::get_cookies(std::map<std::string, std::string, header_comparator>& result) const
87+
size_t http_response::get_cookies(std::map<std::string, std::string, http::header_comparator>& result) const
8888
{
8989
result = this->cookies;
9090
return result.size();
@@ -103,7 +103,7 @@ void http_response::get_raw_response_str(MHD_Response** response, webserver* ws)
103103

104104
void http_response::decorate_response_str(MHD_Response* response)
105105
{
106-
map<string, string, header_comparator>::iterator it;
106+
map<string, string, http::header_comparator>::iterator it;
107107

108108
for (it=headers.begin() ; it != headers.end(); ++it)
109109
MHD_add_response_header(
@@ -300,5 +300,5 @@ std::ostream &operator<< (std::ostream &os, const http_response &r)
300300
return os;
301301
}
302302

303-
303+
304304
};

src/httpserver/http_request.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ namespace http
4444
class arg_comparator;
4545
};
4646

47-
using namespace http;
48-
4947
/**
5048
* Class representing an abstraction for an Http Request. It is used from classes using these apis to receive information through http protocol.
5149
**/
@@ -194,25 +192,25 @@ class http_request
194192
* @param result a map<string, string> > that will be filled with all headers
195193
* @result the size of the map
196194
**/
197-
size_t get_headers(std::map<std::string, std::string, header_comparator>& result) const;
195+
size_t get_headers(std::map<std::string, std::string, http::header_comparator>& result) const;
198196
/**
199197
* Method used to get all footers passed with the request.
200198
* @param result a map<string, string> > that will be filled with all footers
201199
* @result the size of the map
202200
**/
203-
size_t get_footers(std::map<std::string, std::string, header_comparator>& result) const;
201+
size_t get_footers(std::map<std::string, std::string, http::header_comparator>& result) const;
204202
/**
205203
* Method used to get all cookies passed with the request.
206204
* @param result a map<string, string> > that will be filled with all cookies
207205
* @result the size of the map
208206
**/
209-
size_t get_cookies(std::map<std::string, std::string, header_comparator>& result) const;
207+
size_t get_cookies(std::map<std::string, std::string, http::header_comparator>& result) const;
210208
/**
211209
* Method used to get all args passed with the request.
212210
* @param result a map<string, string> > that will be filled with all args
213211
* @result the size of the map
214212
**/
215-
size_t get_args(std::map<std::string, std::string, arg_comparator>& result) const;
213+
size_t get_args(std::map<std::string, std::string, http::arg_comparator>& result) const;
216214
/**
217215
* Method used to get a specific header passed with the request.
218216
* @param key the specific header to get the value from
@@ -394,10 +392,10 @@ class http_request
394392
std::string digested_user;
395393
std::string method;
396394
std::vector<std::string> post_path;
397-
std::map<std::string, std::string, header_comparator> headers;
398-
std::map<std::string, std::string, header_comparator> footers;
399-
std::map<std::string, std::string, header_comparator> cookies;
400-
std::map<std::string, std::string, arg_comparator> args;
395+
std::map<std::string, std::string, http::header_comparator> headers;
396+
std::map<std::string, std::string, http::header_comparator> footers;
397+
std::map<std::string, std::string, http::header_comparator> cookies;
398+
std::map<std::string, std::string, http::arg_comparator> args;
401399
std::string querystring;
402400
std::string content;
403401
std::string version;
@@ -481,7 +479,7 @@ class http_request
481479
{
482480
this->path = path;
483481
std::vector<std::string> complete_path;
484-
http_utils::tokenize_url(this->path, complete_path);
482+
http::http_utils::tokenize_url(this->path, complete_path);
485483
for(unsigned int i = 0; i < complete_path.size(); i++)
486484
{
487485
this->post_path.push_back(complete_path[i]);

src/httpserver/http_response.hpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ namespace details
5252
struct cache_entry;
5353
};
5454

55-
using namespace http;
56-
5755
class bad_caching_attempt: public std::exception
5856
{
5957
virtual const char* what() const throw()
@@ -70,7 +68,7 @@ typedef ssize_t(*cycle_callback_ptr)(char*, size_t);
7068
class http_response
7169
{
7270
public:
73-
71+
7472
http_response(const http_response_builder& builder);
7573

7674
/**
@@ -167,19 +165,19 @@ class http_response
167165
* @return a map<string,string> containing all headers.
168166
**/
169167
size_t get_headers(
170-
std::map<std::string, std::string, header_comparator>& result
168+
std::map<std::string, std::string, http::header_comparator>& result
171169
) const;
172170

173171
/**
174172
* Method used to get all footers passed with the request.
175173
* @return a map<string,string> containing all footers.
176174
**/
177175
size_t get_footers(
178-
std::map<std::string, std::string, header_comparator>& result
176+
std::map<std::string, std::string, http::header_comparator>& result
179177
) const;
180178

181179
size_t get_cookies(
182-
std::map<std::string, std::string, header_comparator>& result
180+
std::map<std::string, std::string, http::header_comparator>& result
183181
) const;
184182

185183
/**
@@ -248,9 +246,9 @@ class http_response
248246
bool reload_nonce;
249247
int fp;
250248
std::string filename;
251-
std::map<std::string, std::string, header_comparator> headers;
252-
std::map<std::string, std::string, header_comparator> footers;
253-
std::map<std::string, std::string, header_comparator> cookies;
249+
std::map<std::string, std::string, http::header_comparator> headers;
250+
std::map<std::string, std::string, http::header_comparator> footers;
251+
std::map<std::string, std::string, http::header_comparator> cookies;
254252
std::vector<std::string> topics;
255253
int keepalive_secs;
256254
std::string keepalive_msg;
@@ -268,7 +266,7 @@ class http_response
268266
bool completed;
269267

270268
webserver* ws;
271-
struct httpserver_ska connection_id;
269+
struct http::httpserver_ska connection_id;
272270

273271
void get_raw_response_str(MHD_Response** res, webserver* ws = 0x0);
274272
void get_raw_response_file(MHD_Response** res, webserver* ws = 0x0);
@@ -298,14 +296,14 @@ class http_response
298296
friend class http_response_builder;
299297
friend void clone_response(const http_response& hr, http_response** dhr);
300298
friend ssize_t details::cb(void* cls, uint64_t pos, char* buf, size_t max);
301-
friend std::ostream &operator<< (std::ostream &os, const http_response &r);
299+
friend std::ostream &operator<< (std::ostream &os, const http_response &r);
302300
private:
303301
http_response& operator=(const http_response& b);
304302

305303
static ssize_t data_generator (void* cls, uint64_t pos, char* buf, size_t max);
306304
};
307305

308-
std::ostream &operator<< (std::ostream &os, const http_response &r);
306+
std::ostream &operator<< (std::ostream &os, const http_response &r);
309307

310308
};
311309
#endif

src/httpserver/http_response_builder.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ namespace details
4545
struct cache_entry;
4646
};
4747

48-
using namespace http;
49-
5048
struct byte_string
5149
{
5250
public:
@@ -86,9 +84,9 @@ class http_response_builder
8684
_realm(""),
8785
_opaque(""),
8886
_reload_nonce(false),
89-
_headers(std::map<std::string, std::string, header_comparator>()),
90-
_footers(std::map<std::string, std::string, header_comparator>()),
91-
_cookies(std::map<std::string, std::string, header_comparator>()),
87+
_headers(std::map<std::string, std::string, http::header_comparator>()),
88+
_footers(std::map<std::string, std::string, http::header_comparator>()),
89+
_cookies(std::map<std::string, std::string, http::header_comparator>()),
9290
_topics(std::vector<std::string>()),
9391
_keepalive_secs(-1),
9492
_keepalive_msg(""),
@@ -98,7 +96,7 @@ class http_response_builder
9896
_decorate_response(&http_response::decorate_response_str),
9997
_enqueue_response(&http_response::enqueue_response_str)
10098
{
101-
_headers[http_utils::http_header_content_type] = content_type;
99+
_headers[http::http_utils::http_header_content_type] = content_type;
102100
}
103101

104102
http_response_builder(
@@ -113,9 +111,9 @@ class http_response_builder
113111
_realm(""),
114112
_opaque(""),
115113
_reload_nonce(false),
116-
_headers(std::map<std::string, std::string, header_comparator>()),
117-
_footers(std::map<std::string, std::string, header_comparator>()),
118-
_cookies(std::map<std::string, std::string, header_comparator>()),
114+
_headers(std::map<std::string, std::string, http::header_comparator>()),
115+
_footers(std::map<std::string, std::string, http::header_comparator>()),
116+
_cookies(std::map<std::string, std::string, http::header_comparator>()),
119117
_topics(std::vector<std::string>()),
120118
_keepalive_secs(-1),
121119
_keepalive_msg(""),
@@ -125,7 +123,7 @@ class http_response_builder
125123
_decorate_response(&http_response::decorate_response_str),
126124
_enqueue_response(&http_response::enqueue_response_str)
127125
{
128-
_headers[http_utils::http_header_content_type] = content_type;
126+
_headers[http::http_utils::http_header_content_type] = content_type;
129127
}
130128

131129
http_response_builder(const http_response_builder& b):
@@ -243,7 +241,7 @@ class http_response_builder
243241

244242
http_response_builder& shoutCAST_response()
245243
{
246-
_response_code |= http_utils::shoutcast_response;
244+
_response_code |= http::http_utils::shoutcast_response;
247245
return *this;
248246
}
249247

@@ -269,9 +267,9 @@ class http_response_builder
269267
std::string _realm;
270268
std::string _opaque;
271269
bool _reload_nonce;
272-
std::map<std::string, std::string, header_comparator> _headers;
273-
std::map<std::string, std::string, header_comparator> _footers;
274-
std::map<std::string, std::string, header_comparator> _cookies;
270+
std::map<std::string, std::string, http::header_comparator> _headers;
271+
std::map<std::string, std::string, http::header_comparator> _footers;
272+
std::map<std::string, std::string, http::header_comparator> _cookies;
275273
std::vector<std::string> _topics;
276274
int _keepalive_secs;
277275
std::string _keepalive_msg;

0 commit comments

Comments
 (0)