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
02c30e49
Commit
02c30e49
authored
Oct 10, 2018
by
knowledge4igor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Client and Endpoint init API and tiny changes in tests
parent
bf80caf9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
29 deletions
+11
-29
include/pistache/client.h
include/pistache/client.h
+1
-2
include/pistache/endpoint.h
include/pistache/endpoint.h
+1
-1
src/server/endpoint.cc
src/server/endpoint.cc
+1
-1
tests/http_client_test.cc
tests/http_client_test.cc
+8
-17
tests/payload_test.cc
tests/payload_test.cc
+0
-5
tests/streaming_test.cc
tests/streaming_test.cc
+0
-3
No files found.
include/pistache/client.h
View file @
02c30e49
...
...
@@ -306,7 +306,6 @@ public:
:
threads_
(
Default
::
Threads
)
,
maxConnectionsPerHost_
(
Default
::
MaxConnectionsPerHost
)
,
keepAlive_
(
Default
::
KeepAlive
)
{
}
Options
&
threads
(
int
val
);
...
...
@@ -323,7 +322,7 @@ public:
~
Client
();
static
Options
options
();
void
init
(
const
Options
&
options
);
void
init
(
const
Options
&
options
=
Options
()
);
RequestBuilder
get
(
const
std
::
string
&
resource
);
RequestBuilder
post
(
const
std
::
string
&
resource
);
...
...
include/pistache/endpoint.h
View file @
02c30e49
...
...
@@ -38,7 +38,7 @@ public:
listener
.
init
(
std
::
forward
<
Args
>
(
args
)...);
}
void
init
(
const
Options
&
options
);
void
init
(
const
Options
&
options
=
Options
()
);
void
setHandler
(
const
std
::
shared_ptr
<
Handler
>&
handler
);
void
bind
();
...
...
src/server/endpoint.cc
View file @
02c30e49
...
...
@@ -14,7 +14,7 @@ namespace Http {
Endpoint
::
Options
::
Options
()
:
threads_
(
1
)
,
flags_
()
,
flags_
(
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
)
,
backlog_
(
Const
::
MaxBacklog
)
,
maxPayload_
(
Const
::
DefaultMaxPayload
)
{
}
...
...
tests/http_client_test.cc
View file @
02c30e49
...
...
@@ -21,15 +21,12 @@ TEST(http_client_test, one_client_with_one_request) {
const
std
::
string
address
=
"localhost:9079"
;
Http
::
Endpoint
server
(
address
);
auto
flags
=
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
;
auto
server_opts
=
Http
::
Endpoint
::
options
().
flags
(
flags
).
threads
(
1
);
server
.
init
(
server_opts
);
server
.
init
();
server
.
setHandler
(
Http
::
make_handler
<
HelloHandler
>
());
server
.
serveThreaded
();
Http
::
Client
client
;
auto
client_opts
=
Http
::
Client
::
options
();
client
.
init
(
client_opts
);
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
auto
rb
=
client
.
get
(
address
);
...
...
@@ -55,15 +52,12 @@ TEST(http_client_test, one_client_with_multiple_requests) {
const
std
::
string
address
=
"localhost:9080"
;
Http
::
Endpoint
server
(
address
);
auto
flags
=
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
;
auto
server_opts
=
Http
::
Endpoint
::
options
().
flags
(
flags
).
threads
(
1
);
server
.
init
(
server_opts
);
server
.
init
();
server
.
setHandler
(
Http
::
make_handler
<
HelloHandler
>
());
server
.
serveThreaded
();
Http
::
Client
client
;
auto
client_opts
=
Http
::
Client
::
options
().
threads
(
1
).
maxConnectionsPerHost
(
1
);
client
.
init
(
client_opts
);
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
const
int
RESPONSE_SIZE
=
3
;
...
...
@@ -94,20 +88,17 @@ TEST(http_client_test, multiple_clients_with_one_request) {
const
std
::
string
address
=
"localhost:9081"
;
Http
::
Endpoint
server
(
address
);
auto
flags
=
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
;
auto
server_opts
=
Http
::
Endpoint
::
options
().
flags
(
flags
).
threads
(
1
);
server
.
init
(
server_opts
);
server
.
init
();
server
.
setHandler
(
Http
::
make_handler
<
HelloHandler
>
());
server
.
serveThreaded
();
auto
client_opts
=
Http
::
Client
::
options
();
const
int
CLIENT_SIZE
=
3
;
Http
::
Client
client1
;
client1
.
init
(
client_opts
);
client1
.
init
();
Http
::
Client
client2
;
client2
.
init
(
client_opts
);
client2
.
init
();
Http
::
Client
client3
;
client3
.
init
(
client_opts
);
client3
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
int
response_counter
=
0
;
...
...
tests/payload_test.cc
View file @
02c30e49
...
...
@@ -88,11 +88,8 @@ TEST(payload, from_description)
router
.
initFromDescription
(
desc
);
auto
flags
=
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
;
auto
opts
=
Http
::
Endpoint
::
options
()
.
threads
(
threads
)
.
flags
(
flags
)
.
maxPayload
(
maxPayload
);
;
...
...
@@ -142,7 +139,6 @@ TEST(payload, manual_construction) {
Port
port
(
PORT
);
Address
addr
(
Ipv4
::
any
(),
port
);
int
threads
=
20
;
auto
flags
=
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
;
size_t
maxPayload
=
2048
;
auto
pid
=
fork
();
...
...
@@ -150,7 +146,6 @@ TEST(payload, manual_construction) {
auto
endpoint
=
std
::
make_shared
<
Http
::
Endpoint
>
(
addr
);
auto
opts
=
Http
::
Endpoint
::
options
()
.
threads
(
threads
)
.
flags
(
flags
)
.
maxPayload
(
maxPayload
);
;
...
...
tests/streaming_test.cc
View file @
02c30e49
...
...
@@ -63,11 +63,8 @@ TEST(stream, from_description)
router
.
initFromDescription
(
desc
);
auto
flags
=
Tcp
::
Options
::
InstallSignalHandler
|
Tcp
::
Options
::
ReuseAddr
;
auto
opts
=
Http
::
Endpoint
::
options
()
.
threads
(
threads
)
.
flags
(
flags
)
.
maxPayload
(
1024
*
1024
)
;
...
...
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