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
4b5179a5
Commit
4b5179a5
authored
Oct 02, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Fix bug in util::make_hostport
parent
8efccddc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
33 deletions
+15
-33
src/util.cc
src/util.cc
+1
-26
src/util.h
src/util.h
+0
-2
src/util_test.cc
src/util_test.cc
+14
-5
No files found.
src/util.cc
View file @
4b5179a5
...
...
@@ -1147,31 +1147,6 @@ std::string dtos(double n) {
return
utos
(
static_cast
<
int64_t
>
(
n
))
+
"."
+
(
f
.
size
()
==
1
?
"0"
:
""
)
+
f
;
}
std
::
string
make_http_hostport
(
const
StringRef
&
host
,
uint16_t
port
)
{
if
(
port
!=
80
&&
port
!=
443
)
{
return
make_hostport
(
host
,
port
);
}
auto
ipv6
=
ipv6_numeric_addr
(
host
.
c_str
());
std
::
string
hostport
;
hostport
.
resize
(
host
.
size
()
+
(
ipv6
?
2
:
0
));
auto
p
=
&
hostport
[
0
];
if
(
ipv6
)
{
*
p
++
=
'['
;
}
p
=
std
::
copy_n
(
host
.
c_str
(),
host
.
size
(),
p
);
if
(
ipv6
)
{
*
p
++
=
']'
;
}
return
hostport
;
}
StringRef
make_http_hostport
(
BlockAllocator
&
balloc
,
const
StringRef
&
host
,
uint16_t
port
)
{
if
(
port
!=
80
&&
port
!=
443
)
{
...
...
@@ -1244,7 +1219,7 @@ StringRef make_hostport(BlockAllocator &balloc, const StringRef &host,
*
p
++
=
':'
;
std
::
copy
(
std
::
begin
(
serv
),
std
::
end
(
serv
),
p
);
p
=
std
::
copy
(
std
::
begin
(
serv
),
std
::
end
(
serv
),
p
);
*
p
=
'\0'
;
...
...
src/util.h
View file @
4b5179a5
...
...
@@ -633,8 +633,6 @@ std::string format_duration(double t);
// Creates "host:port" string using given |host| and |port|. If
// |host| is numeric IPv6 address (e.g., ::1), it is enclosed by "["
// and "]". If |port| is 80 or 443, port part is omitted.
std
::
string
make_http_hostport
(
const
StringRef
&
host
,
uint16_t
port
);
StringRef
make_http_hostport
(
BlockAllocator
&
balloc
,
const
StringRef
&
host
,
uint16_t
port
);
...
...
src/util_test.cc
View file @
4b5179a5
...
...
@@ -502,12 +502,15 @@ void test_util_parse_config_str_list(void) {
}
void
test_util_make_http_hostport
(
void
)
{
CU_ASSERT
(
"localhost"
==
util
::
make_http_hostport
(
StringRef
::
from_lit
(
"localhost"
),
80
));
BlockAllocator
balloc
(
4096
,
4096
);
CU_ASSERT
(
"localhost"
==
util
::
make_http_hostport
(
balloc
,
StringRef
::
from_lit
(
"localhost"
),
80
));
CU_ASSERT
(
"[::1]"
==
util
::
make_http_hostport
(
StringRef
::
from_lit
(
"::1"
),
443
));
CU_ASSERT
(
"localhost:3000"
==
util
::
make_http_hostport
(
StringRef
::
from_lit
(
"localhost"
),
3000
));
util
::
make_http_hostport
(
balloc
,
StringRef
::
from_lit
(
"::1"
),
443
));
CU_ASSERT
(
"localhost:3000"
==
util
::
make_http_hostport
(
balloc
,
StringRef
::
from_lit
(
"localhost"
),
3000
));
}
void
test_util_make_hostport
(
void
)
{
...
...
@@ -515,6 +518,12 @@ void test_util_make_hostport(void) {
util
::
make_hostport
(
StringRef
::
from_lit
(
"localhost"
),
80
));
CU_ASSERT
(
"[::1]:443"
==
util
::
make_hostport
(
StringRef
::
from_lit
(
"::1"
),
443
));
BlockAllocator
balloc
(
4096
,
4096
);
CU_ASSERT
(
"localhost:80"
==
util
::
make_hostport
(
balloc
,
StringRef
::
from_lit
(
"localhost"
),
80
));
CU_ASSERT
(
"[::1]:443"
==
util
::
make_hostport
(
balloc
,
StringRef
::
from_lit
(
"::1"
),
443
));
}
void
test_util_strifind
(
void
)
{
...
...
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