Skip to content

Commit 86aecb8

Browse files
committed
Deprecating http_client guarantee_order option.
1 parent 62e50bd commit 86aecb8

File tree

3 files changed

+8
-73
lines changed

3 files changed

+8
-73
lines changed

Release/include/cpprest/http_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class http_client_config
189189
/// Set the 'guarantee order' property
190190
/// </summary>
191191
/// <param name="guarantee_order">The value of the property.</param>
192+
CASABLANCA_DEPRECATED("Confusing API will be removed in future releases. If you need to order HTTP requests use task continuations.")
192193
void set_guarantee_order(bool guarantee_order)
193194
{
194195
m_guarantee_order = guarantee_order;

Release/tests/functional/http/client/connections_and_errors.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,15 @@ using namespace tests::functional::http::utilities;
3838
namespace tests { namespace functional { namespace http { namespace client {
3939

4040
// Test implementation for pending_requests_after_client.
41-
static void pending_requests_after_client_impl(uri address, bool guarantee_order)
41+
static void pending_requests_after_client_impl(const uri &address)
4242
{
4343
test_http_server::scoped_server scoped(address);
4444
const method mtd = methods::GET;
4545

4646
const size_t num_requests = 10;
4747
std::vector<pplx::task<http_response>> responses;
4848
{
49-
http_client_config config;
50-
config.set_guarantee_order(guarantee_order);
51-
http_client client(address, config);
49+
http_client client(address);
5250

5351
// send requests.
5452
for(size_t i = 0; i < num_requests; ++i)
@@ -87,8 +85,7 @@ SUITE(connections_and_errors)
8785
// Tests requests still outstanding after the http_client has been destroyed.
8886
TEST_FIXTURE(uri_address, pending_requests_after_client)
8987
{
90-
pending_requests_after_client_impl(m_uri, true);
91-
pending_requests_after_client_impl(m_uri, false);
88+
pending_requests_after_client_impl(m_uri);
9289
}
9390

9491
TEST_FIXTURE(uri_address, server_doesnt_exist)

Release/tests/functional/http/client/multiple_requests.cpp

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/***
22
* ==++==
33
*
4-
* Copyright (c) Microsoft Corporation. All rights reserved.
4+
* Copyright (c) Microsoft Corporation. All rights reserved.
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,8 +16,6 @@
1616
* ==--==
1717
* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
1818
*
19-
* multiple_requests.cpp
20-
*
2119
* Tests cases for multiple requests and responses from an http_client.
2220
*
2321
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
@@ -55,67 +53,6 @@ static void initialize_data(std::string *data_arrays, const size_t count)
5553
SUITE(multiple_requests)
5654
{
5755

58-
TEST_FIXTURE(uri_address, single_tcp_connection)
59-
{
60-
test_http_server::scoped_server scoped(m_uri);
61-
http_client_config config;
62-
config.set_guarantee_order(true);
63-
http_client client(m_uri, config);
64-
65-
const size_t num_requests = 20;
66-
std::string request_bodies[num_requests];
67-
initialize_data(request_bodies, num_requests);
68-
const method method = methods::PUT;
69-
const web::http::status_code code = status_codes::OK;
70-
71-
// setup to handle requests on the server side.
72-
// If any of the requests come in before the response is sent the test fails.
73-
auto requests = scoped.server()->next_requests(num_requests);
74-
volatile unsigned long response_sent = 0;
75-
requests[0].then([&](test_request *request)
76-
{
77-
http_asserts::assert_test_request_equals(request, method, U("/"), U("text/plain"), to_string_t(request_bodies[0]));
78-
// wait a bit to see if the other requests will come.
79-
os_utilities::sleep(500);
80-
os_utilities::interlocked_increment(&response_sent);
81-
VERIFY_ARE_EQUAL(0u, request->reply(code));
82-
});
83-
for(size_t i = 1; i < num_requests; ++i)
84-
{
85-
requests[i].then([i, &response_sent, &code, &method, &request_bodies](test_request *request)
86-
{
87-
if(os_utilities::interlocked_increment(&response_sent) == 1)
88-
{
89-
VERIFY_IS_TRUE(false);
90-
}
91-
http_asserts::assert_test_request_equals(request, method, U("/"), U("text/plain"), to_string_t(request_bodies[i]));
92-
VERIFY_ARE_EQUAL(0u, request->reply(code));
93-
});
94-
}
95-
96-
// send requests
97-
std::vector<pplx::task<http_response>> responses;
98-
for(size_t i = 0; i < num_requests; ++i)
99-
{
100-
http_request msg(method);
101-
msg.set_body(request_bodies[i]);
102-
responses.push_back(client.request(msg));
103-
}
104-
105-
// wait for requests.
106-
for(size_t i = 0; i < num_requests; ++i)
107-
{
108-
try
109-
{
110-
http_asserts::assert_response_equals(responses[i].get(), code);
111-
}
112-
catch (...)
113-
{
114-
VERIFY_IS_FALSE(false);
115-
}
116-
}
117-
}
118-
11956
TEST_FIXTURE(uri_address, requests_with_data)
12057
{
12158
test_http_server::scoped_server scoped(m_uri);
@@ -147,7 +84,7 @@ TEST_FIXTURE(uri_address, requests_with_data)
14784
http_asserts::assert_test_request_equals(request, method, U("/"), U("text/plain"), to_string_t(request_body));
14885
VERIFY_ARE_EQUAL(0u, request->reply(code));
14986
}
150-
87+
15188
// wait for requests.
15289
for(size_t i = 0; i < num_requests; ++i)
15390
{
@@ -190,7 +127,7 @@ TEST_FIXTURE(uri_address, responses_with_data)
190127
http_asserts::assert_test_request_equals(request, method, U("/"));
191128
VERIFY_ARE_EQUAL(0u, request->reply(code, U(""), headers, request_body));
192129
}
193-
130+
194131
// wait for requests.
195132
for(size_t i = 0; i < num_requests; ++i)
196133
{

0 commit comments

Comments
 (0)