File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 22#define CPR_LOW_SPEED_H
33
44#include < cstdint>
5+ #include < chrono>
56
67namespace cpr {
78
89class LowSpeed {
910 public:
10- LowSpeed (const std::int32_t p_limit, const std::int32_t p_time) : limit(p_limit), time(p_time) {}
11+
12+ [[deprecated(" Will be removed in CPR 2.x - Use the constructor with std::chrono::seconds instead of std::int32_t" )]]
13+ LowSpeed (const std::int32_t p_limit, const std::int32_t p_time) : limit(p_limit), time(std::chrono::seconds(p_time)) {}
14+
15+ LowSpeed (const std::int32_t p_limit, const std::chrono::seconds p_time) : limit(p_limit), time(p_time) {}
1116
1217 std::int32_t limit;
13- std::int32_t time;
18+ std::chrono::seconds time;
1419};
1520
1621} // namespace cpr
Original file line number Diff line number Diff line change @@ -59,14 +59,14 @@ TEST(ErrorTests, ChronoConnectTimeoutFailure) {
5959
6060TEST (ErrorTests, LowSpeedTimeFailure) {
6161 Url url{server->GetBaseUrl () + " /low_speed.html" };
62- Response response = cpr::Get (url, cpr::LowSpeed{1000 , 1 });
62+ Response response = cpr::Get (url, cpr::LowSpeed{1000 , std::chrono::seconds ( 1 ) });
6363 // Do not check for the HTTP status code, since libcurl always provides the status code of the header if it was received
6464 EXPECT_EQ (ErrorCode::OPERATION_TIMEDOUT, response.error .code );
6565}
6666
6767TEST (ErrorTests, LowSpeedBytesFailure) {
6868 Url url{server->GetBaseUrl () + " /low_speed_bytes.html" };
69- Response response = cpr::Get (url, cpr::LowSpeed{1000 , 1 });
69+ Response response = cpr::Get (url, cpr::LowSpeed{1000 , std::chrono::seconds ( 1 ) });
7070 // Do not check for the HTTP status code, since libcurl always provides the status code of the header if it was received
7171 EXPECT_EQ (ErrorCode::OPERATION_TIMEDOUT, response.error .code );
7272}
Original file line number Diff line number Diff line change @@ -591,7 +591,7 @@ TEST(LowSpeedTests, SetLowSpeedTest) {
591591 Url url{server->GetBaseUrl () + " /hello.html" };
592592 Session session;
593593 session.SetUrl (url);
594- session.SetLowSpeed ({1 , 1 });
594+ session.SetLowSpeed ({1 , std::chrono::seconds ( 1 ) });
595595 Response response = session.Get ();
596596 std::string expected_text{" Hello world!" };
597597 EXPECT_EQ (expected_text, response.text );
You can’t perform that action at this time.
0 commit comments