Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
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
pistache
Commits
5bb31160
Unverified
Commit
5bb31160
authored
Jun 11, 2019
by
Kip Warner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/headers_test.cc: Added registered_header_in_raw_list unit test for #551
parent
49b42f81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletion
+43
-1
tests/headers_test.cc
tests/headers_test.cc
+43
-1
No files found.
tests/headers_test.cc
View file @
5bb31160
#include <pistache/http
_headers
.h>
#include <pistache/http.h>
#include <pistache/date.h>
#include "gtest/gtest.h"
...
...
@@ -647,3 +647,45 @@ TEST(headers_test, could_not_find_header)
ASSERT_TRUE
(
"Unknown header"
==
what
);
}
// Verify registered headers appear in both the client request's strongly typed
// and raw lists...
TEST
(
headers_test
,
registered_header_in_raw_list
)
{
// Make sure TestHeader is registered because Googletest does not guarantee
// add_new_header_test will be run before this test...
if
(
!
Pistache
::
Http
::
Header
::
Registry
::
instance
().
isRegistered
(
TestHeader
::
Name
))
Pistache
::
Http
::
Header
::
Registry
::
instance
().
registerHeader
<
TestHeader
>
();
// Verify test header is registered...
ASSERT_TRUE
(
Pistache
::
Http
::
Header
::
Registry
::
instance
().
isRegistered
(
TestHeader
::
Name
));
// Prepare a client request header string that should use our registered
// TestHeader...
std
::
string
line
=
std
::
string
(
TestHeader
::
Name
)
+
": some data
\r\n
"
;
// Prepare to load the client test header string...
Pistache
::
RawStreamBuf
<>
buf
(
&
line
[
0
],
line
.
size
());
Pistache
::
StreamCursor
cursor
(
&
buf
);
// Simulate server deserializing the client's header request...
Pistache
::
Http
::
Request
request
;
Pistache
::
Http
::
Private
::
HeadersStep
step
(
&
request
);
step
.
apply
(
cursor
);
// Retrieve all of the headers the client submitted in their request...
const
auto
&
headersCollection
=
request
.
headers
();
// Verify our TestHeader is in the strongly typed list...
ASSERT_TRUE
(
headersCollection
.
has
<
TestHeader
>
());
// Obtain the raw header list...
const
auto
&
rawHeadersList
=
headersCollection
.
rawList
();
// Verify the TestHeader is in the raw list as expected...
const
auto
foundRawHeader
=
rawHeadersList
.
find
(
TestHeader
::
Name
);
ASSERT_TRUE
(
foundRawHeader
!=
rawHeadersList
.
end
());
ASSERT_TRUE
(
foundRawHeader
->
second
.
name
()
==
TestHeader
::
Name
);
ASSERT_TRUE
(
foundRawHeader
->
second
.
value
()
==
"some data"
);
}
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