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
2a56a3d9
Commit
2a56a3d9
authored
Jan 25, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Fix te request header handling
Checking against "trailers" is enough for now.
parent
1883bdaf
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
8 additions
and
105 deletions
+8
-105
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+7
-7
src/http2.cc
src/http2.cc
+0
-32
src/http2.h
src/http2.h
+0
-6
src/http2_test.cc
src/http2_test.cc
+0
-56
src/http2_test.h
src/http2_test.h
+0
-1
src/shrpx-unittest.cc
src/shrpx-unittest.cc
+0
-2
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+1
-1
No files found.
integration-tests/nghttpx_http2_test.go
View file @
2a56a3d9
...
...
@@ -317,16 +317,16 @@ func TestH2H1AssembleCookies(t *testing.T) {
}
}
// TestH2H1TETrailer
tests that server accepts TE request header field
//
if it has trailer
only.
func
TestH2H1TETrailer
(
t
*
testing
.
T
)
{
// TestH2H1TETrailer
s tests that server accepts TE request header
//
field if it has trailers
only.
func
TestH2H1TETrailer
s
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1TETrailer"
,
name
:
"TestH2H1TETrailer
s
"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"te"
,
"trailer"
),
pair
(
"te"
,
"trailer
s
"
),
},
})
if
err
!=
nil
{
...
...
@@ -337,8 +337,8 @@ func TestH2H1TETrailer(t *testing.T) {
}
}
// TestH2H1TEGzip tests that server reset
stream if TE request
//
header
field contains gzip.
// TestH2H1TEGzip tests that server reset
s stream if TE request header
// field contains gzip.
func
TestH2H1TEGzip
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Error
(
"server should not forward bad request"
)
...
...
src/http2.cc
View file @
2a56a3d9
...
...
@@ -664,38 +664,6 @@ const Headers::value_type *get_header(const int *hdidx, int token,
return
&
nva
[
i
];
}
bool
check_http2_te
(
const
uint8_t
*
value
,
size_t
valuelen
)
{
auto
first
=
value
;
auto
last
=
first
+
valuelen
;
for
(;;)
{
if
(
first
==
last
)
{
return
true
;
}
auto
end_param
=
std
::
find
(
first
,
last
,
','
);
auto
len
=
end_param
-
first
;
if
(
!
util
::
istartsWith
(
reinterpret_cast
<
const
char
*>
(
first
),
len
,
"trailer"
))
{
return
false
;
}
if
(
len
==
sizeof
(
"trailer"
)
-
1
)
{
goto
next
;
}
switch
(
first
[
sizeof
(
"trailer"
)
-
1
])
{
case
' '
:
case
';'
:
goto
next
;
}
return
false
;
next:
if
(
end_param
==
last
)
{
return
true
;
}
first
=
std
::
find_if_not
(
end_param
+
1
,
last
,
[](
uint8_t
c
)
{
return
c
==
' '
||
c
==
'\t'
||
c
==
','
;
});
}
}
}
// namespace http2
}
// namespace nghttp2
src/http2.h
View file @
2a56a3d9
...
...
@@ -244,12 +244,6 @@ bool http2_mandatory_request_headers_presence(const int *hdidx);
const
Headers
::
value_type
*
get_header
(
const
int
*
hdidx
,
int
token
,
const
Headers
&
nva
);
// Returns true if TE request header field value |value| of length
// |valuelen| is empty or only contains "trailers". The valid header
// field value is "trailer" and optionally followed by "," or OWS for
// simplicity.
bool
check_http2_te
(
const
uint8_t
*
value
,
size_t
valuelen
);
}
// namespace http2
}
// namespace nghttp2
...
...
src/http2_test.cc
View file @
2a56a3d9
...
...
@@ -290,60 +290,4 @@ void test_http2_mandatory_request_headers_presence(void) {
CU_ASSERT
(
http2
::
http2_mandatory_request_headers_presence
(
hdidx
));
}
void
test_http2_check_http2_te
(
void
)
{
{
const
uint8_t
v
[]
=
"trailer"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"Trailer"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer,"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer,,"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer, ,"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer, , "
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer; q=0.9"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer ; q=0.9"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer ; q=0.9, trailer"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailer ; q=0.9, trailer"
;
CU_ASSERT
(
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
// failure cases
{
const
uint8_t
v
[]
=
"trailer; q=0.9, gzip"
;
CU_ASSERT
(
!
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"traile"
;
CU_ASSERT
(
!
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
{
const
uint8_t
v
[]
=
"trailerr"
;
CU_ASSERT
(
!
http2
::
check_http2_te
(
v
,
sizeof
(
v
)
-
1
));
}
}
}
// namespace shrpx
src/http2_test.h
View file @
2a56a3d9
...
...
@@ -39,7 +39,6 @@ void test_http2_lookup_token(void);
void
test_http2_check_http2_pseudo_header
(
void
);
void
test_http2_http2_header_allowed
(
void
);
void
test_http2_mandatory_request_headers_presence
(
void
);
void
test_http2_check_http2_te
(
void
);
}
// namespace shrpx
...
...
src/shrpx-unittest.cc
View file @
2a56a3d9
...
...
@@ -93,8 +93,6 @@ int main(int argc, char *argv[]) {
shrpx
::
test_http2_http2_header_allowed
)
||
!
CU_add_test
(
pSuite
,
"http2_mandatory_request_headers_presence"
,
shrpx
::
test_http2_mandatory_request_headers_presence
)
||
!
CU_add_test
(
pSuite
,
"http2_check_http2_te"
,
shrpx
::
test_http2_check_http2_te
)
||
!
CU_add_test
(
pSuite
,
"downstream_index_request_headers"
,
shrpx
::
test_downstream_index_request_headers
)
||
!
CU_add_test
(
pSuite
,
"downstream_index_response_headers"
,
...
...
src/shrpx_http2_upstream.cc
View file @
2a56a3d9
...
...
@@ -226,7 +226,7 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
break
;
}
case
http2
:
:
HD_TE
:
if
(
!
http2
::
check_http2_te
(
value
,
valuelen
))
{
if
(
!
util
::
strieq
(
"trailers"
,
value
,
valuelen
))
{
upstream
->
rst_stream
(
downstream
,
NGHTTP2_PROTOCOL_ERROR
);
return
NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE
;
}
...
...
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