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
614953be
Unverified
Commit
614953be
authored
Jul 07, 2021
by
Kip
Committed by
GitHub
Jul 07, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #957 from Tachi107/experimental-client
Move the Http client to `Pistache::Experimental`
parents
23b88dd0
10e205e8
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
30 deletions
+33
-30
examples/http_client.cc
examples/http_client.cc
+2
-2
include/pistache/client.h
include/pistache/client.h
+1
-1
include/pistache/http.h
include/pistache/http.h
+4
-1
src/client/client.cc
src/client/client.cc
+1
-1
tests/cookie_test_3.cc
tests/cookie_test_3.cc
+2
-2
tests/http_client_test.cc
tests/http_client_test.cc
+16
-16
tests/http_server_test.cc
tests/http_server_test.cc
+4
-4
tests/request_size_test.cc
tests/request_size_test.cc
+2
-2
tests/threadname_test.cc
tests/threadname_test.cc
+1
-1
No files found.
examples/http_client.cc
View file @
614953be
...
...
@@ -33,9 +33,9 @@ int main(int argc, char* argv[])
count
=
std
::
stoi
(
argv
[
2
]);
}
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
auto
opts
=
Http
::
Client
::
options
().
threads
(
1
).
maxConnectionsPerHost
(
8
);
auto
opts
=
Http
::
Experimental
::
Client
::
options
().
threads
(
1
).
maxConnectionsPerHost
(
8
);
client
.
init
(
opts
);
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
include/pistache/client.h
View file @
614953be
...
...
@@ -27,7 +27,7 @@
#include <string>
#include <unordered_map>
namespace
Pistache
::
Http
namespace
Pistache
::
Http
::
Experimental
{
namespace
Default
...
...
include/pistache/http.h
View file @
614953be
...
...
@@ -168,13 +168,16 @@ namespace Pistache
};
}
// namespace Uri
// Remove when RequestBuilder will be out of namespace Experimental
namespace
Experimental
{
class
RequestBuilder
;
};
// 5. Request
class
Request
:
public
Message
{
public:
friend
class
Private
::
RequestLineStep
;
friend
class
RequestBuilder
;
friend
class
Experimental
::
RequestBuilder
;
Request
()
=
default
;
...
...
src/client/client.cc
View file @
614953be
...
...
@@ -26,7 +26,7 @@
#include <sstream>
#include <string>
namespace
Pistache
::
Http
namespace
Pistache
::
Http
::
Experimental
{
using
NotifyOn
=
Polling
::
NotifyOn
;
...
...
tests/cookie_test_3.cc
View file @
614953be
...
...
@@ -48,7 +48,7 @@ TEST(http_client_test, one_client_with_one_request_with_onecookie)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -87,7 +87,7 @@ TEST(http_client_test, one_client_with_one_request_with_several_cookies)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
tests/http_client_test.cc
View file @
614953be
...
...
@@ -101,7 +101,7 @@ TEST(http_client_test, one_client_with_one_request)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
auto
rb
=
client
.
get
(
server_address
);
...
...
@@ -138,7 +138,7 @@ TEST(http_client_test, one_client_with_multiple_requests)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -184,11 +184,11 @@ TEST(http_client_test, multiple_clients_with_one_request)
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
const
int
CLIENT_SIZE
=
3
;
Http
::
Client
client1
;
Http
::
Experimental
::
Client
client1
;
client1
.
init
();
Http
::
Client
client2
;
Http
::
Experimental
::
Client
client2
;
client2
.
init
();
Http
::
Client
client3
;
Http
::
Experimental
::
Client
client3
;
client3
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -249,7 +249,7 @@ TEST(http_client_test, timeout_reject)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
auto
rb
=
client
.
get
(
server_address
).
timeout
(
std
::
chrono
::
milliseconds
(
1000
));
...
...
@@ -284,8 +284,8 @@ TEST(
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
auto
opts
=
Http
::
Client
::
options
().
maxConnectionsPerHost
(
1
).
threads
(
2
);
Http
::
Experimental
::
Client
client
;
auto
opts
=
Http
::
Experimental
::
Client
::
options
().
maxConnectionsPerHost
(
1
).
threads
(
2
);
client
.
init
(
opts
);
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -333,8 +333,8 @@ TEST(
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
auto
opts
=
Http
::
Client
::
options
().
maxConnectionsPerHost
(
2
).
threads
(
1
);
Http
::
Experimental
::
Client
client
;
auto
opts
=
Http
::
Experimental
::
Client
::
options
().
maxConnectionsPerHost
(
2
).
threads
(
1
);
client
.
init
(
opts
);
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -380,7 +380,7 @@ TEST(http_client_test, test_client_timeout)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -441,7 +441,7 @@ TEST(http_client_test, client_sends_query)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
string
queryStr
;
...
...
@@ -513,8 +513,8 @@ TEST(http_client_test, client_get_large_content)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
auto
opts
=
Http
::
Client
::
options
().
maxResponseSize
(
8192
);
Http
::
Experimental
::
Client
client
;
auto
opts
=
Http
::
Experimental
::
Client
::
options
().
maxResponseSize
(
8192
);
client
.
init
(
opts
);
auto
response
=
client
.
get
(
server_address
).
send
();
...
...
@@ -554,8 +554,8 @@ TEST(http_client_test, client_do_not_get_large_content)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
std
::
cout
<<
"Server address: "
<<
server_address
<<
"
\n
"
;
Http
::
Client
client
;
auto
opts
=
Http
::
Client
::
options
().
maxResponseSize
(
4096
);
Http
::
Experimental
::
Client
client
;
auto
opts
=
Http
::
Experimental
::
Client
::
options
().
maxResponseSize
(
4096
);
client
.
init
(
opts
);
auto
response
=
client
.
get
(
server_address
).
send
();
...
...
tests/http_server_test.cc
View file @
614953be
...
...
@@ -194,7 +194,7 @@ struct PingHandler : public Http::Handler
int
clientLogicFunc
(
size_t
response_size
,
const
std
::
string
&
server_page
,
int
timeout_seconds
,
int
wait_seconds
)
{
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
@@ -401,7 +401,7 @@ TEST(http_server_test, server_with_static_file)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
LOGGER
(
"test"
,
"Server address: "
<<
server_address
);
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
auto
rb
=
client
.
get
(
server_address
);
auto
response
=
rb
.
send
();
...
...
@@ -443,7 +443,7 @@ TEST(http_server_test, server_request_copies_address)
const
std
::
string
server_address
=
"localhost:"
+
server
.
getPort
().
toString
();
LOGGER
(
"test"
,
"Server address: "
<<
server_address
);
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
auto
rb
=
client
.
get
(
server_address
);
auto
response
=
rb
.
send
();
...
...
@@ -511,7 +511,7 @@ TEST(http_server_test, response_size_captured)
// Use the built-in http client, but this test is interested in testing
// that the ResponseWriter in the server stashed the correct size and code
// values.
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
auto
rb
=
client
.
get
(
server_address
);
auto
response
=
rb
.
send
();
...
...
tests/request_size_test.cc
View file @
614953be
...
...
@@ -49,8 +49,8 @@ void testRequestSizes(const std::string& url,
RequestSizeTestSets
testResults
;
std
::
mutex
resultsetMutex
;
Http
::
Client
client
;
auto
client_opts
=
Http
::
Client
::
options
().
threads
(
3
).
maxConnectionsPerHost
(
3
);
Http
::
Experimental
::
Client
client
;
auto
client_opts
=
Http
::
Experimental
::
Client
::
options
().
threads
(
3
).
maxConnectionsPerHost
(
3
);
client
.
init
(
client_opts
);
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
tests/threadname_test.cc
View file @
614953be
...
...
@@ -40,7 +40,7 @@ struct HelloHandlerWithDelay : public Http::Handler
int
clientLogicFunc
(
int
response_size
,
const
std
::
string
&
server_page
,
int
wait_seconds
)
{
Http
::
Client
client
;
Http
::
Experimental
::
Client
client
;
client
.
init
();
std
::
vector
<
Async
::
Promise
<
Http
::
Response
>>
responses
;
...
...
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