Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
49fa914d
Commit
49fa914d
authored
Feb 14, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Use StringRef for string parameters in match_downstream_addr_group
parent
93eabc64
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
18 deletions
+18
-18
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+9
-6
src/shrpx_config.cc
src/shrpx_config.cc
+5
-7
src/shrpx_config.h
src/shrpx_config.h
+1
-1
src/shrpx_router.cc
src/shrpx_router.cc
+2
-3
src/shrpx_router.h
src/shrpx_router.h
+1
-1
No files found.
src/shrpx_client_handler.cc
View file @
49fa914d
...
@@ -681,16 +681,19 @@ ClientHandler::get_downstream_connection(Downstream *downstream) {
...
@@ -681,16 +681,19 @@ ClientHandler::get_downstream_connection(Downstream *downstream) {
}
else
{
}
else
{
auto
&
router
=
get_config
()
->
router
;
auto
&
router
=
get_config
()
->
router
;
if
(
!
req
.
authority
.
empty
())
{
if
(
!
req
.
authority
.
empty
())
{
group
=
match_downstream_addr_group
(
router
,
req
.
authority
,
req
.
path
,
group
=
groups
,
catch_all
);
match_downstream_addr_group
(
router
,
StringRef
{
req
.
authority
},
StringRef
{
req
.
path
},
groups
,
catch_all
);
}
else
{
}
else
{
auto
h
=
req
.
fs
.
header
(
http2
::
HD_HOST
);
auto
h
=
req
.
fs
.
header
(
http2
::
HD_HOST
);
if
(
h
)
{
if
(
h
)
{
group
=
match_downstream_addr_group
(
router
,
h
->
value
,
req
.
path
,
groups
,
group
=
catch_all
);
match_downstream_addr_group
(
router
,
StringRef
{
h
->
value
},
StringRef
{
req
.
path
},
groups
,
catch_all
);
}
else
{
}
else
{
group
=
match_downstream_addr_group
(
router
,
""
,
req
.
path
,
groups
,
group
=
catch_all
);
match_downstream_addr_group
(
router
,
StringRef
::
from_lit
(
""
),
StringRef
{
req
.
path
},
groups
,
catch_all
);
}
}
}
}
}
}
...
...
src/shrpx_config.cc
View file @
49fa914d
...
@@ -2504,7 +2504,7 @@ int int_syslog_facility(const char *strfacility) {
...
@@ -2504,7 +2504,7 @@ int int_syslog_facility(const char *strfacility) {
namespace
{
namespace
{
size_t
match_downstream_addr_group_host
(
size_t
match_downstream_addr_group_host
(
const
Router
&
router
,
const
std
::
string
&
host
,
const
StringRef
&
path
,
const
Router
&
router
,
const
StringRef
&
host
,
const
StringRef
&
path
,
const
std
::
vector
<
DownstreamAddrGroup
>
&
groups
,
size_t
catch_all
)
{
const
std
::
vector
<
DownstreamAddrGroup
>
&
groups
,
size_t
catch_all
)
{
if
(
path
.
empty
()
||
path
[
0
]
!=
'/'
)
{
if
(
path
.
empty
()
||
path
[
0
]
!=
'/'
)
{
auto
group
=
router
.
match
(
host
,
StringRef
::
from_lit
(
"/"
));
auto
group
=
router
.
match
(
host
,
StringRef
::
from_lit
(
"/"
));
...
@@ -2548,11 +2548,9 @@ size_t match_downstream_addr_group_host(
...
@@ -2548,11 +2548,9 @@ size_t match_downstream_addr_group_host(
}
}
}
// namespace
}
// namespace
size_t
size_t
match_downstream_addr_group
(
match_downstream_addr_group
(
const
Router
&
router
,
const
std
::
string
&
hostport
,
const
Router
&
router
,
const
StringRef
&
hostport
,
const
StringRef
&
raw_path
,
const
std
::
string
&
raw_path
,
const
std
::
vector
<
DownstreamAddrGroup
>
&
groups
,
size_t
catch_all
)
{
const
std
::
vector
<
DownstreamAddrGroup
>
&
groups
,
size_t
catch_all
)
{
if
(
std
::
find
(
std
::
begin
(
hostport
),
std
::
end
(
hostport
),
'/'
)
!=
if
(
std
::
find
(
std
::
begin
(
hostport
),
std
::
end
(
hostport
),
'/'
)
!=
std
::
end
(
hostport
))
{
std
::
end
(
hostport
))
{
// We use '/' specially, and if '/' is included in host, it breaks
// We use '/' specially, and if '/' is included in host, it breaks
...
@@ -2589,7 +2587,7 @@ match_downstream_addr_group(const Router &router, const std::string &hostport,
...
@@ -2589,7 +2587,7 @@ match_downstream_addr_group(const Router &router, const std::string &hostport,
}
}
util
::
inp_strlower
(
host
);
util
::
inp_strlower
(
host
);
return
match_downstream_addr_group_host
(
router
,
host
,
path
,
groups
,
return
match_downstream_addr_group_host
(
router
,
StringRef
{
host
}
,
path
,
groups
,
catch_all
);
catch_all
);
}
}
...
...
src/shrpx_config.h
View file @
49fa914d
...
@@ -652,7 +652,7 @@ read_tls_ticket_key_file(const std::vector<std::string> &files,
...
@@ -652,7 +652,7 @@ read_tls_ticket_key_file(const std::vector<std::string> &files,
// group. The catch-all group index is given in |catch_all|. All
// group. The catch-all group index is given in |catch_all|. All
// patterns are given in |groups|.
// patterns are given in |groups|.
size_t
match_downstream_addr_group
(
size_t
match_downstream_addr_group
(
const
Router
&
router
,
const
std
::
string
&
hostport
,
const
std
::
string
&
path
,
const
Router
&
router
,
const
StringRef
&
hostport
,
const
StringRef
&
path
,
const
std
::
vector
<
DownstreamAddrGroup
>
&
groups
,
size_t
catch_all
);
const
std
::
vector
<
DownstreamAddrGroup
>
&
groups
,
size_t
catch_all
);
}
// namespace shrpx
}
// namespace shrpx
...
...
src/shrpx_router.cc
View file @
49fa914d
...
@@ -259,12 +259,11 @@ const RNode *match_partial(const RNode *node, size_t offset, const char *first,
...
@@ -259,12 +259,11 @@ const RNode *match_partial(const RNode *node, size_t offset, const char *first,
}
}
}
// namespace
}
// namespace
ssize_t
Router
::
match
(
const
std
::
string
&
host
,
const
StringRef
&
path
)
const
{
ssize_t
Router
::
match
(
const
StringRef
&
host
,
const
StringRef
&
path
)
const
{
const
RNode
*
node
;
const
RNode
*
node
;
size_t
offset
;
size_t
offset
;
node
=
node
=
match_complete
(
&
offset
,
&
root_
,
std
::
begin
(
host
),
std
::
end
(
host
));
match_complete
(
&
offset
,
&
root_
,
host
.
c_str
(),
host
.
c_str
()
+
host
.
size
());
if
(
node
==
nullptr
)
{
if
(
node
==
nullptr
)
{
return
-
1
;
return
-
1
;
}
}
...
...
src/shrpx_router.h
View file @
49fa914d
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
// Adds route |pattern| with its |index|.
// Adds route |pattern| with its |index|.
bool
add_route
(
const
StringRef
&
pattern
,
size_t
index
);
bool
add_route
(
const
StringRef
&
pattern
,
size_t
index
);
// Returns the matched index of pattern. -1 if there is no match.
// Returns the matched index of pattern. -1 if there is no match.
ssize_t
match
(
const
std
::
string
&
host
,
const
StringRef
&
path
)
const
;
ssize_t
match
(
const
StringRef
&
host
,
const
StringRef
&
path
)
const
;
void
add_node
(
RNode
*
node
,
const
char
*
pattern
,
size_t
patlen
,
size_t
index
);
void
add_node
(
RNode
*
node
,
const
char
*
pattern
,
size_t
patlen
,
size_t
index
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment