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
65c3ce4a
Commit
65c3ce4a
authored
Sep 10, 2018
by
Ian Roddis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing payload_test
parent
a66ad1e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
tests/payload_test.cc
tests/payload_test.cc
+22
-19
No files found.
tests/payload_test.cc
View file @
65c3ce4a
...
...
@@ -30,29 +30,32 @@ typedef std::vector<TestSet> PayloadTestSets;
void
testPayloads
(
std
::
string
url
,
PayloadTestSets
&
testPayloads
)
{
// Client tests to make sure the payload is enforced
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>
>
responses
;
std
::
mutex
resultsetMutex
;
PayloadTestSets
test_results
;
for
(
size_t
times
=
0
;
times
<
10
;
++
times
)
{
Http
::
Client
client
;
auto
client_opts
=
Http
::
Client
::
options
().
threads
(
1
).
maxConnectionsPerHost
(
1
);
auto
client_opts
=
Http
::
Client
::
options
()
.
threads
(
1
)
.
maxConnectionsPerHost
(
1
);
client
.
init
(
client_opts
);
for
(
auto
&
t
:
testPayloads
)
{
auto
rb
=
client
.
post
(
url
);
for
(
auto
&
t
:
testPayloads
)
{
std
::
string
payload
(
t
.
bytes
,
'A'
);
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>
>
responses
;
auto
response
=
rb
.
body
(
payload
).
send
();
response
.
then
([
t
,
&
test_results
](
Http
::
Response
rsp
)
{
response
.
then
([
t
,
&
test_results
,
&
resultsetMutex
](
Http
::
Response
rsp
)
{
TestSet
res
(
t
);
res
.
actualCode
=
rsp
.
code
();
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
resultsetMutex
);
test_results
.
push_back
(
res
);
}
},
Async
::
IgnoreException
);
responses
.
push_back
(
std
::
move
(
response
));
}
auto
sync
=
Async
::
whenAll
(
responses
.
begin
(),
responses
.
end
());
Async
::
Barrier
<
std
::
vector
<
Http
::
Response
>>
barrier
(
sync
);
barrier
.
wait_for
(
std
::
chrono
::
seconds
(
5
));
client
.
shutdown
();
}
client
.
shutdown
();
for
(
auto
&
result
:
test_results
)
{
ASSERT_EQ
(
result
.
expectedCode
,
result
.
actualCode
);
...
...
@@ -66,7 +69,7 @@ void handleEcho(const Rest::Request&req, Http::ResponseWriter response) {
TEST
(
payload_test
,
from_description
)
{
Address
addr
(
Ipv4
::
any
(),
9084
);
const
size_t
threads
=
2
;
const
size_t
threads
=
2
0
;
const
size_t
maxPayload
=
1024
;
// very small
std
::
shared_ptr
<
Http
::
Endpoint
>
endpoint
;
...
...
@@ -128,7 +131,7 @@ TEST(payload_test, manual_construction) {
};
Port
port
(
9080
);
int
thr
=
2
;
int
thr
=
2
0
;
Address
addr
(
Ipv4
::
any
(),
port
);
auto
endpoint
=
std
::
make_shared
<
Http
::
Endpoint
>
(
addr
);
size_t
maxPayload
=
2048
;
...
...
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