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
d3561a63
Commit
d3561a63
authored
Apr 17, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp: Depend on "leader" anchor if js is linked inside head element
parent
1a12a9b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
src/HtmlParser.cc
src/HtmlParser.cc
+20
-4
src/HtmlParser.h
src/HtmlParser.h
+3
-0
src/nghttp.cc
src/nghttp.cc
+1
-0
No files found.
src/HtmlParser.cc
View file @
d3561a63
...
...
@@ -30,7 +30,8 @@
namespace
nghttp2
{
ParserData
::
ParserData
(
const
std
::
string
&
base_uri
)
:
base_uri
(
base_uri
)
{}
ParserData
::
ParserData
(
const
std
::
string
&
base_uri
)
:
base_uri
(
base_uri
),
inside_head
(
0
)
{}
HtmlParser
::
HtmlParser
(
const
std
::
string
&
base_uri
)
:
base_uri_
(
base_uri
),
parser_ctx_
(
nullptr
),
parser_data_
(
base_uri
)
{}
...
...
@@ -68,6 +69,9 @@ namespace {
void
start_element_func
(
void
*
user_data
,
const
xmlChar
*
name
,
const
xmlChar
**
attrs
)
{
auto
parser_data
=
static_cast
<
ParserData
*>
(
user_data
);
if
(
util
::
strieq
(
reinterpret_cast
<
const
char
*>
(
name
),
"head"
))
{
++
parser_data
->
inside_head
;
}
if
(
util
::
strieq
(
reinterpret_cast
<
const
char
*>
(
name
),
"link"
))
{
auto
rel_attr
=
get_attr
(
attrs
,
"rel"
);
auto
href_attr
=
get_attr
(
attrs
,
"href"
);
...
...
@@ -90,8 +94,20 @@ void start_element_func(void *user_data, const xmlChar *name,
if
(
!
src_attr
)
{
return
;
}
// TODO if script is inside in head, this should be REQ_LEADERS.
add_link
(
parser_data
,
src_attr
,
REQ_UNBLOCK_JS
);
if
(
parser_data
->
inside_head
)
{
add_link
(
parser_data
,
src_attr
,
REQ_JS
);
}
else
{
add_link
(
parser_data
,
src_attr
,
REQ_UNBLOCK_JS
);
}
}
}
}
// namespace
namespace
{
void
end_element_func
(
void
*
user_data
,
const
xmlChar
*
name
)
{
auto
parser_data
=
static_cast
<
ParserData
*>
(
user_data
);
if
(
util
::
strieq
(
reinterpret_cast
<
const
char
*>
(
name
),
"head"
))
{
--
parser_data
->
inside_head
;
}
}
}
// namespace
...
...
@@ -113,7 +129,7 @@ xmlSAXHandler saxHandler = {
nullptr
,
// startDocumentSAXFunc
nullptr
,
// endDocumentSAXFunc
&
start_element_func
,
// startElementSAXFunc
nullptr
,
// endElementSAXFunc
&
end_element_func
,
// endElementSAXFunc
nullptr
,
// referenceSAXFunc
nullptr
,
// charactersSAXFunc
nullptr
,
// ignorableWhitespaceSAXFunc
...
...
src/HtmlParser.h
View file @
d3561a63
...
...
@@ -41,6 +41,7 @@ namespace nghttp2 {
// Lower value has higher priority
enum
RequestPriority
{
REQ_CSS
=
1
,
REQ_JS
,
REQ_UNBLOCK_JS
,
REQ_IMG
,
REQ_OTHERS
,
...
...
@@ -49,6 +50,8 @@ enum RequestPriority {
struct
ParserData
{
std
::
string
base_uri
;
std
::
vector
<
std
::
pair
<
std
::
string
,
RequestPriority
>>
links
;
// > 0 if we are inside "head" element.
int
inside_head
;
ParserData
(
const
std
::
string
&
base_uri
);
};
...
...
src/nghttp.cc
View file @
d3561a63
...
...
@@ -196,6 +196,7 @@ nghttp2_priority_spec Request::resolve_dep(int32_t pri) {
int32_t
weight
;
switch
(
pri
)
{
case
REQ_CSS
:
case
REQ_JS
:
anchor_id
=
anchors
[
ANCHOR_LEADERS
].
stream_id
;
weight
=
2
;
break
;
...
...
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