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
8471c9e9
Commit
8471c9e9
authored
Nov 07, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Parse te header field a bit more properly
parent
f5a4c9d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
1 deletion
+48
-1
src/http2.cc
src/http2.cc
+25
-0
src/http2.h
src/http2.h
+3
-0
src/http2_test.cc
src/http2_test.cc
+16
-0
src/http2_test.h
src/http2_test.h
+1
-0
src/shrpx-unittest.cc
src/shrpx-unittest.cc
+2
-0
src/shrpx_http2_downstream_connection.cc
src/shrpx_http2_downstream_connection.cc
+1
-1
No files found.
src/http2.cc
View file @
8471c9e9
...
@@ -1665,6 +1665,31 @@ StringRef copy_lower(BlockAllocator &balloc, const StringRef &src) {
...
@@ -1665,6 +1665,31 @@ StringRef copy_lower(BlockAllocator &balloc, const StringRef &src) {
return
StringRef
{
iov
.
base
,
p
};
return
StringRef
{
iov
.
base
,
p
};
}
}
bool
contains_trailers
(
const
StringRef
&
s
)
{
constexpr
auto
trailers
=
StringRef
::
from_lit
(
"trailers"
);
for
(
auto
p
=
std
::
begin
(
s
),
end
=
std
::
end
(
s
);;
++
p
)
{
p
=
std
::
find_if
(
p
,
end
,
[](
char
c
)
{
return
c
!=
' '
&&
c
!=
'\t'
;
});
if
(
p
==
end
||
end
-
p
<
trailers
.
size
())
{
return
false
;
}
if
(
util
::
strieq
(
trailers
,
StringRef
{
p
,
p
+
trailers
.
size
()}))
{
// Make sure that there is no character other than white spaces
// before next "," or end of string.
p
=
std
::
find_if
(
p
+
trailers
.
size
(),
end
,
[](
char
c
)
{
return
c
!=
' '
&&
c
!=
'\t'
;
});
if
(
p
==
end
||
*
p
==
','
)
{
return
true
;
}
}
// Skip to next ",".
p
=
std
::
find_if
(
p
,
end
,
[](
char
c
)
{
return
c
==
','
;
});
if
(
p
==
end
)
{
return
false
;
}
}
}
}
// namespace http2
}
// namespace http2
}
// namespace nghttp2
}
// namespace nghttp2
src/http2.h
View file @
8471c9e9
...
@@ -384,6 +384,9 @@ int construct_push_component(BlockAllocator &balloc, StringRef &scheme,
...
@@ -384,6 +384,9 @@ int construct_push_component(BlockAllocator &balloc, StringRef &scheme,
// Copies |src| and return its lower-cased version.
// Copies |src| and return its lower-cased version.
StringRef
copy_lower
(
BlockAllocator
&
balloc
,
const
StringRef
&
src
);
StringRef
copy_lower
(
BlockAllocator
&
balloc
,
const
StringRef
&
src
);
// Returns true if te header field value |s| contains "trailers".
bool
contains_trailers
(
const
StringRef
&
s
);
}
// namespace http2
}
// namespace http2
}
// namespace nghttp2
}
// namespace nghttp2
...
...
src/http2_test.cc
View file @
8471c9e9
...
@@ -962,4 +962,20 @@ void test_http2_construct_push_component(void) {
...
@@ -962,4 +962,20 @@ void test_http2_construct_push_component(void) {
CU_ASSERT
(
"/b/?q=a"
==
path
);
CU_ASSERT
(
"/b/?q=a"
==
path
);
}
}
void
test_http2_contains_trailers
(
void
)
{
CU_ASSERT
(
!
http2
::
contains_trailers
(
StringRef
::
from_lit
(
""
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"trailers"
)));
// Match must be case-insensitive.
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"TRAILERS"
)));
CU_ASSERT
(
!
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"trailer"
)));
CU_ASSERT
(
!
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"trailers 3"
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"trailers,"
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"trailers,foo"
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"foo,trailers"
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"foo,trailers,bar"
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
"foo, trailers ,bar"
)));
CU_ASSERT
(
http2
::
contains_trailers
(
StringRef
::
from_lit
(
",trailers"
)));
}
}
// namespace shrpx
}
// namespace shrpx
src/http2_test.h
View file @
8471c9e9
...
@@ -46,6 +46,7 @@ void test_http2_normalize_path(void);
...
@@ -46,6 +46,7 @@ void test_http2_normalize_path(void);
void
test_http2_rewrite_clean_path
(
void
);
void
test_http2_rewrite_clean_path
(
void
);
void
test_http2_get_pure_path_component
(
void
);
void
test_http2_get_pure_path_component
(
void
);
void
test_http2_construct_push_component
(
void
);
void
test_http2_construct_push_component
(
void
);
void
test_http2_contains_trailers
(
void
);
}
// namespace shrpx
}
// namespace shrpx
...
...
src/shrpx-unittest.cc
View file @
8471c9e9
...
@@ -102,6 +102,8 @@ int main(int argc, char *argv[]) {
...
@@ -102,6 +102,8 @@ int main(int argc, char *argv[]) {
shrpx
::
test_http2_get_pure_path_component
)
||
shrpx
::
test_http2_get_pure_path_component
)
||
!
CU_add_test
(
pSuite
,
"http2_construct_push_component"
,
!
CU_add_test
(
pSuite
,
"http2_construct_push_component"
,
shrpx
::
test_http2_construct_push_component
)
||
shrpx
::
test_http2_construct_push_component
)
||
!
CU_add_test
(
pSuite
,
"http2_contains_trailers"
,
shrpx
::
test_http2_contains_trailers
)
||
!
CU_add_test
(
pSuite
,
"downstream_field_store_append_last_header"
,
!
CU_add_test
(
pSuite
,
"downstream_field_store_append_last_header"
,
shrpx
::
test_downstream_field_store_append_last_header
)
||
shrpx
::
test_downstream_field_store_append_last_header
)
||
!
CU_add_test
(
pSuite
,
"downstream_field_store_header"
,
!
CU_add_test
(
pSuite
,
"downstream_field_store_header"
,
...
...
src/shrpx_http2_downstream_connection.cc
View file @
8471c9e9
...
@@ -402,7 +402,7 @@ int Http2DownstreamConnection::push_request_headers() {
...
@@ -402,7 +402,7 @@ int Http2DownstreamConnection::push_request_headers() {
// HTTP/1 upstream request can contain keyword other than
// HTTP/1 upstream request can contain keyword other than
// "trailers". We just forward "trailers".
// "trailers". We just forward "trailers".
// TODO more strict handling required here.
// TODO more strict handling required here.
if
(
te
&&
util
::
strifind
(
te
->
value
,
StringRef
::
from_lit
(
"trailers"
)
))
{
if
(
te
&&
http2
::
contains_trailers
(
te
->
value
))
{
nva
.
push_back
(
http2
::
make_nv_ll
(
"te"
,
"trailers"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
"te"
,
"trailers"
));
}
}
...
...
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