Skip to content

Commit 501f82f

Browse files
author
Sebastiano Merlino
committed
Retabbed code
1 parent e792f12 commit 501f82f

File tree

11 files changed

+1447
-1447
lines changed

11 files changed

+1447
-1447
lines changed

src/HttpEndpoint.cpp

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -28,75 +28,75 @@ namespace httpserver
2828
using namespace http;
2929
//ENDPOINT
3030
HttpEndpoint::HttpEndpoint(const string& url, bool family, bool registration):
31-
url_complete(string_utilities::to_lower_copy(url)),
32-
url_modded("/"),
33-
family_url(family),
31+
url_complete(string_utilities::to_lower_copy(url)),
32+
url_modded("/"),
33+
family_url(family),
3434
reg_compiled(false)
3535
{
36-
vector<string> parts = HttpUtils::tokenizeUrl(url);
37-
string buffered;
38-
bool first = true;
36+
vector<string> parts = HttpUtils::tokenizeUrl(url);
37+
string buffered;
38+
bool first = true;
3939
if(registration)
4040
{
4141
for(unsigned int i = 0; i< parts.size(); i++)
4242
{
43-
if((parts[i] != "") && (parts[i][0] != '{'))
44-
{
45-
if(first)
46-
{
47-
if(parts[i][0] == '^')
48-
{
49-
this->url_modded = parts[i];
50-
}
51-
else
52-
{
53-
this->url_modded += parts[i];
54-
}
55-
first = false;
56-
}
57-
else
58-
{
59-
this->url_modded += "/" + parts[i];
60-
}
61-
}
62-
else
63-
{
64-
if(( parts[i].size() >= 3) && (parts[i][0] == '{') && (parts[i][parts[i].size() - 1] == '}') )
65-
{
66-
int bar = parts[i].find_first_of('|');
67-
if(bar != (int)string::npos)
68-
{
69-
this->url_pars.push_back(parts[i].substr(1, bar - 1));
70-
if(first)
71-
{
72-
this->url_modded += parts[i].substr(bar + 1, parts[i].size() - bar - 2);
73-
first = false;
74-
}
75-
else
76-
{
77-
this->url_modded += "/"+parts[i].substr(bar + 1, parts[i].size() - bar - 2);
78-
}
79-
}
80-
else
81-
{
82-
this->url_pars.push_back(parts[i].substr(1,parts[i].size() - 2));
83-
if(first)
84-
{
85-
this->url_modded += "([^\\/]+)";
86-
first = false;
87-
}
88-
else
89-
{
90-
this->url_modded += "/([^\\/]+)";
91-
}
92-
}
93-
this->chunk_positions.push_back(i);
94-
}
95-
else
96-
{
97-
// RITORNARE ECCEZIONE
98-
}
99-
}
43+
if((parts[i] != "") && (parts[i][0] != '{'))
44+
{
45+
if(first)
46+
{
47+
if(parts[i][0] == '^')
48+
{
49+
this->url_modded = parts[i];
50+
}
51+
else
52+
{
53+
this->url_modded += parts[i];
54+
}
55+
first = false;
56+
}
57+
else
58+
{
59+
this->url_modded += "/" + parts[i];
60+
}
61+
}
62+
else
63+
{
64+
if(( parts[i].size() >= 3) && (parts[i][0] == '{') && (parts[i][parts[i].size() - 1] == '}') )
65+
{
66+
int bar = parts[i].find_first_of('|');
67+
if(bar != (int)string::npos)
68+
{
69+
this->url_pars.push_back(parts[i].substr(1, bar - 1));
70+
if(first)
71+
{
72+
this->url_modded += parts[i].substr(bar + 1, parts[i].size() - bar - 2);
73+
first = false;
74+
}
75+
else
76+
{
77+
this->url_modded += "/"+parts[i].substr(bar + 1, parts[i].size() - bar - 2);
78+
}
79+
}
80+
else
81+
{
82+
this->url_pars.push_back(parts[i].substr(1,parts[i].size() - 2));
83+
if(first)
84+
{
85+
this->url_modded += "([^\\/]+)";
86+
first = false;
87+
}
88+
else
89+
{
90+
this->url_modded += "/([^\\/]+)";
91+
}
92+
}
93+
this->chunk_positions.push_back(i);
94+
}
95+
else
96+
{
97+
// RITORNARE ECCEZIONE
98+
}
99+
}
100100
this->url_pieces.push_back(parts[i]);
101101
}
102102
regcomp(&(this->re_url_modded), url_modded.c_str(), REG_EXTENDED|REG_ICASE);
@@ -106,19 +106,19 @@ HttpEndpoint::HttpEndpoint(const string& url, bool family, bool registration):
106106
{
107107
for(unsigned int i = 0; i< parts.size(); i++)
108108
{
109-
if(first)
110-
{
111-
this->url_modded += parts[i];
112-
first = false;
113-
}
114-
else
115-
{
116-
this->url_modded += "/" + parts[i];
117-
}
109+
if(first)
110+
{
111+
this->url_modded += parts[i];
112+
first = false;
113+
}
114+
else
115+
{
116+
this->url_modded += "/" + parts[i];
117+
}
118118
this->url_pieces.push_back(parts[i]);
119119
}
120120
}
121-
// this->re_url_modded = boost::xpressive::sregex::compile( url_modded, boost::xpressive::regex_constants::icase );
121+
// this->re_url_modded = boost::xpressive::sregex::compile( url_modded, boost::xpressive::regex_constants::icase );
122122
}
123123

124124
HttpEndpoint::HttpEndpoint(const HttpEndpoint& h)
@@ -150,35 +150,35 @@ HttpEndpoint& HttpEndpoint::operator =(const HttpEndpoint& h)
150150

151151
bool HttpEndpoint::operator <(const HttpEndpoint& b) const
152152
{
153-
return string_utilities::to_lower_copy(this->url_modded) < string_utilities::to_lower_copy(b.url_modded);
153+
return string_utilities::to_lower_copy(this->url_modded) < string_utilities::to_lower_copy(b.url_modded);
154154
}
155155

156156
bool HttpEndpoint::match(const HttpEndpoint& url) const
157157
{
158-
if(this->family_url && (url.url_pieces.size() >= this->url_pieces.size()))
159-
{
160-
string nn = "/";
161-
bool first = true;
162-
for(unsigned int i = 0; i < this->url_pieces.size(); i++)
163-
{
164-
if(first)
165-
{
166-
nn += url.url_pieces[i];
167-
first = false;
168-
}
169-
else
170-
{
171-
nn += "/" + url.url_pieces[i];
172-
}
173-
}
158+
if(this->family_url && (url.url_pieces.size() >= this->url_pieces.size()))
159+
{
160+
string nn = "/";
161+
bool first = true;
162+
for(unsigned int i = 0; i < this->url_pieces.size(); i++)
163+
{
164+
if(first)
165+
{
166+
nn += url.url_pieces[i];
167+
first = false;
168+
}
169+
else
170+
{
171+
nn += "/" + url.url_pieces[i];
172+
}
173+
}
174174
return regexec(&(this->re_url_modded), nn.c_str(), 0, NULL, 0) == 0;
175-
// return boost::xpressive::regex_match(nn, this->re_url_modded);
176-
}
177-
else
178-
{
175+
// return boost::xpressive::regex_match(nn, this->re_url_modded);
176+
}
177+
else
178+
{
179179
return regexec(&(this->re_url_modded), url.url_modded.c_str(), 0, NULL, 0) == 0;
180-
// return boost::xpressive::regex_match(url.url_modded, this->re_url_modded);
181-
}
180+
// return boost::xpressive::regex_match(url.url_modded, this->re_url_modded);
181+
}
182182
}
183183

184184
};

0 commit comments

Comments
 (0)