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
1e8bea15
Commit
1e8bea15
authored
Mar 03, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Use StringRef inside LinkHeader
parent
aaf01773
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
24 deletions
+23
-24
src/http2.cc
src/http2.cc
+19
-18
src/http2.h
src/http2.h
+2
-2
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+2
-4
No files found.
src/http2.cc
View file @
1e8bea15
...
...
@@ -892,26 +892,26 @@ std::pair<LinkHeader, const char *>
parse_next_link_header_once
(
const
char
*
first
,
const
char
*
last
)
{
first
=
skip_to_next_field
(
first
,
last
);
if
(
first
==
last
||
*
first
!=
'<'
)
{
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
auto
url_first
=
++
first
;
first
=
std
::
find
(
first
,
last
,
'>'
);
if
(
first
==
last
)
{
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
auto
url_last
=
first
++
;
if
(
first
==
last
)
{
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
// we expect ';' or ',' here
switch
(
*
first
)
{
case
','
:
return
{{
{
nullptr
,
nullptr
}},
++
first
};
return
{{
StringRef
{
}},
++
first
};
case
';'
:
++
first
;
break
;
default:
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
auto
ok
=
false
;
...
...
@@ -919,7 +919,7 @@ parse_next_link_header_once(const char *first, const char *last) {
for
(;;)
{
first
=
skip_lws
(
first
,
last
);
if
(
first
==
last
)
{
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
// we expect link-param
...
...
@@ -943,7 +943,7 @@ parse_next_link_header_once(const char *first, const char *last) {
}
if
(
start
==
first
)
{
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
if
(
!
ok
&&
start
+
PLTLEN
==
first
&&
...
...
@@ -958,7 +958,7 @@ parse_next_link_header_once(const char *first, const char *last) {
start
=
first
;
}
if
(
first
==
last
)
{
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
assert
(
*
first
==
'"'
);
++
first
;
...
...
@@ -970,7 +970,7 @@ parse_next_link_header_once(const char *first, const char *last) {
// parse next link-param
continue
;
}
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
// we are only interested in rel=preload parameter. Others are
// simply skipped.
...
...
@@ -1045,11 +1045,11 @@ parse_next_link_header_once(const char *first, const char *last) {
if
(
*
first
==
'='
||
*
first
==
';'
||
*
first
==
','
)
{
break
;
}
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
if
(
param_first
==
first
)
{
// empty parmname
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
// link-param without value is acceptable (see link-extension) if
// it is not followed by '='
...
...
@@ -1066,13 +1066,13 @@ parse_next_link_header_once(const char *first, const char *last) {
++
first
;
if
(
first
==
last
)
{
// empty value is not acceptable
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
if
(
*
first
==
'"'
)
{
// quoted-string
first
=
skip_to_right_dquote
(
first
+
1
,
last
);
if
(
first
==
last
)
{
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
++
first
;
if
(
first
==
last
||
*
first
==
','
)
{
...
...
@@ -1083,12 +1083,12 @@ parse_next_link_header_once(const char *first, const char *last) {
// parse next link-param
continue
;
}
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
// not quoted-string, skip to next ',' or ';'
if
(
*
first
==
','
||
*
first
==
';'
)
{
// empty value
return
{{
{
nullptr
,
nullptr
}},
last
};
return
{{
StringRef
{
}},
last
};
}
for
(;
first
!=
last
;
++
first
)
{
if
(
*
first
==
','
||
*
first
==
';'
)
{
...
...
@@ -1112,7 +1112,7 @@ almost_done:
if
(
ok
&&
!
ign
)
{
return
{{{
url_first
,
url_last
}},
first
};
}
return
{{
{
nullptr
,
nullptr
}},
first
};
return
{{
StringRef
{
}},
first
};
}
}
// namespace
...
...
@@ -1123,8 +1123,9 @@ std::vector<LinkHeader> parse_link_header(const char *src, size_t len) {
for
(;
first
!=
last
;)
{
auto
rv
=
parse_next_link_header_once
(
first
,
last
);
first
=
rv
.
second
;
if
(
rv
.
first
.
uri
.
first
!=
nullptr
&&
rv
.
first
.
uri
.
second
!=
nullptr
)
{
res
.
push_back
(
rv
.
first
);
auto
&
link
=
rv
.
first
;
if
(
!
link
.
uri
.
empty
())
{
res
.
push_back
(
link
);
}
}
return
res
;
...
...
src/http2.h
View file @
1e8bea15
...
...
@@ -287,8 +287,8 @@ Headers::value_type *get_header(const HeaderIndex &hdidx, int32_t token,
Headers
&
nva
);
struct
LinkHeader
{
// The region of URI
is [uri.first, uri.second)
.
std
::
pair
<
const
char
*
,
const
char
*>
uri
;
// The region of URI
. This might not be NULL-terminated
.
StringRef
uri
;
};
// Returns next URI-reference in Link header field value |src| of
...
...
src/shrpx_http2_upstream.cc
View file @
1e8bea15
...
...
@@ -1752,14 +1752,12 @@ int Http2Upstream::prepare_push_promise(Downstream *downstream) {
for
(
auto
&
link
:
http2
::
parse_link_header
(
kv
.
value
.
c_str
(),
kv
.
value
.
size
()))
{
auto
uri
=
link
.
uri
.
first
;
auto
len
=
link
.
uri
.
second
-
link
.
uri
.
first
;
const
std
::
string
*
scheme_ptr
,
*
authority_ptr
;
std
::
string
scheme
,
authority
,
path
;
rv
=
http2
::
construct_push_component
(
scheme
,
authority
,
path
,
base
,
baselen
,
uri
,
len
);
baselen
,
link
.
uri
.
c_str
(),
link
.
uri
.
size
());
if
(
rv
!=
0
)
{
continue
;
}
...
...
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