Skip to content

Commit 28288a7

Browse files
authored
Merge pull request #154 from etr/lazy_path_pieces
Lazy path pieces
2 parents cce5227 + b4c307b commit 28288a7

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Sat Aug 10 18:34:07 2019 -0800
2+
Added support for TCP-NODELAY
3+
Changed set_path on http_request to have lazy behavior
4+
15
Tue Aug 06 22:22:14 2019 -0800
26
Added support for body parsing in DELETE requests.
37
Added support for PATCH method

src/httpserver/http_request.hpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class http_request
8383
* Method used to get all pieces of the path requested; considering an url splitted by '/'.
8484
* @return a vector of strings containing all pieces
8585
**/
86-
const std::vector<std::string>& get_path_pieces() const
86+
const std::vector<std::string> get_path_pieces() const
8787
{
88-
return this->post_path;
88+
return http::http_utils::tokenize_url(this->path);
8989
}
9090

9191
/**
@@ -95,8 +95,9 @@ class http_request
9595
**/
9696
const std::string& get_path_piece(int index) const
9797
{
98-
if(((int)(this->post_path.size())) > index)
99-
return this->post_path[index];
98+
std::vector<std::string> post_path = this->get_path_pieces();
99+
if(((int)(post_path.size())) > index)
100+
return post_path[index];
100101
return EMPTY;
101102
}
102103

@@ -238,7 +239,6 @@ class http_request
238239
http_request(const http_request& b):
239240
path(b.path),
240241
method(b.method),
241-
post_path(b.post_path),
242242
args(b.args),
243243
content(b.content),
244244
content_size_limit(b.content_size_limit),
@@ -251,7 +251,6 @@ class http_request
251251
http_request(http_request&& b) noexcept:
252252
path(std::move(b.path)),
253253
method(std::move(b.method)),
254-
post_path(std::move(b.post_path)),
255254
args(std::move(b.args)),
256255
content(std::move(b.content)),
257256
content_size_limit(b.content_size_limit),
@@ -266,7 +265,6 @@ class http_request
266265

267266
this->path = b.path;
268267
this->method = b.method;
269-
this->post_path = b.post_path;
270268
this->args = b.args;
271269
this->content = b.content;
272270
this->content_size_limit = b.content_size_limit;
@@ -282,7 +280,6 @@ class http_request
282280

283281
this->path = std::move(b.path);
284282
this->method = std::move(b.method);
285-
this->post_path = std::move(b.post_path);
286283
this->args = std::move(b.args);
287284
this->content = std::move(b.content);
288285
this->content_size_limit = b.content_size_limit;
@@ -294,7 +291,6 @@ class http_request
294291

295292
std::string path;
296293
std::string method;
297-
std::vector<std::string> post_path;
298294
std::map<std::string, std::string, http::arg_comparator> args;
299295
std::string content;
300296
size_t content_size_limit;
@@ -377,11 +373,6 @@ class http_request
377373
void set_path(const std::string& path)
378374
{
379375
this->path = path;
380-
std::vector<std::string> complete_path = http::http_utils::tokenize_url(this->path);
381-
for(unsigned int i = 0; i < complete_path.size(); i++)
382-
{
383-
this->post_path.push_back(complete_path[i]);
384-
}
385376
}
386377

387378
/**

0 commit comments

Comments
 (0)