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
6f70a53d
Commit
6f70a53d
authored
Dec 15, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: http2::add_header: strip white spaces in value
parent
93ee9e30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
src/http2.cc
src/http2.cc
+9
-0
src/http2.h
src/http2.h
+1
-1
src/http2_test.cc
src/http2_test.cc
+30
-0
No files found.
src/http2.cc
View file @
6f70a53d
...
...
@@ -316,6 +316,15 @@ Headers::value_type to_header(const uint8_t *name, size_t namelen,
void
add_header
(
Headers
&
nva
,
const
uint8_t
*
name
,
size_t
namelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
bool
no_index
)
{
if
(
valuelen
>
0
)
{
size_t
i
,
j
;
for
(
i
=
0
;
i
<
valuelen
&&
(
value
[
i
]
==
' '
||
value
[
i
]
==
'\t'
);
++
i
)
;
for
(
j
=
valuelen
-
1
;
j
>
i
&&
(
value
[
j
]
==
' '
||
value
[
j
]
==
'\t'
);
--
j
)
;
value
+=
i
;
valuelen
-=
i
+
(
valuelen
-
j
-
1
);
}
nva
.
push_back
(
to_header
(
name
,
namelen
,
value
,
valuelen
,
no_index
));
}
...
...
src/http2.h
View file @
6f70a53d
...
...
@@ -111,7 +111,7 @@ Headers::value_type to_header(const uint8_t *name, size_t namelen,
// Add name/value pairs to |nva|. If |no_index| is true, this
// name/value pair won't be indexed when it is forwarded to the next
// hop.
// hop.
This function strips white spaces around |value|.
void
add_header
(
Headers
&
nva
,
const
uint8_t
*
name
,
size_t
namelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
bool
no_index
);
...
...
src/http2_test.cc
View file @
6f70a53d
...
...
@@ -68,6 +68,36 @@ void test_http2_add_header(void) {
true
);
CU_ASSERT
(
Headers
::
value_type
(
"alpha"
,
""
)
==
nva
[
0
]);
CU_ASSERT
(
nva
[
0
].
no_index
);
nva
.
clear
();
http2
::
add_header
(
nva
,
(
const
uint8_t
*
)
"a"
,
1
,
(
const
uint8_t
*
)
" b"
,
2
,
false
);
CU_ASSERT
(
Headers
::
value_type
(
"a"
,
"b"
)
==
nva
[
0
]);
nva
.
clear
();
http2
::
add_header
(
nva
,
(
const
uint8_t
*
)
"a"
,
1
,
(
const
uint8_t
*
)
"b "
,
2
,
false
);
CU_ASSERT
(
Headers
::
value_type
(
"a"
,
"b"
)
==
nva
[
0
]);
nva
.
clear
();
http2
::
add_header
(
nva
,
(
const
uint8_t
*
)
"a"
,
1
,
(
const
uint8_t
*
)
" b "
,
5
,
false
);
CU_ASSERT
(
Headers
::
value_type
(
"a"
,
"b"
)
==
nva
[
0
]);
nva
.
clear
();
http2
::
add_header
(
nva
,
(
const
uint8_t
*
)
"a"
,
1
,
(
const
uint8_t
*
)
" bravo "
,
9
,
false
);
CU_ASSERT
(
Headers
::
value_type
(
"a"
,
"bravo"
)
==
nva
[
0
]);
nva
.
clear
();
http2
::
add_header
(
nva
,
(
const
uint8_t
*
)
"a"
,
1
,
(
const
uint8_t
*
)
" "
,
4
,
false
);
CU_ASSERT
(
Headers
::
value_type
(
"a"
,
""
)
==
nva
[
0
]);
}
void
test_http2_check_http2_headers
(
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