Skip to content

Commit c1dbea5

Browse files
committed
Merge branch 'development' of https://git01.codeplex.com/casablanca into nuget
2 parents 9070763 + 30bc94b commit c1dbea5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1460
-1125
lines changed

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ DeCarabas
1515
luisfeliu
1616
intercommiura
1717
halex2005
18+
simonlep
1819

1920
AutoDesk Inc.
2021
Cyrille Fauvel (cyrillef)

Release/include/cpprest/asyncrt_utils.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,43 @@ namespace conversions
184184
_ASYNCRTIMP std::vector<unsigned char> __cdecl from_base64(const utility::string_t& str);
185185

186186
template <typename Source>
187-
utility::string_t print_string(const Source &val)
187+
utility::string_t print_string(const Source &val, const std::locale &loc)
188188
{
189189
utility::ostringstream_t oss;
190+
oss.imbue(loc);
190191
oss << val;
191192
if (oss.bad())
193+
{
192194
throw std::bad_cast();
195+
}
193196
return oss.str();
194197
}
198+
199+
template <typename Source>
200+
utility::string_t print_string(const Source &val)
201+
{
202+
return print_string(val, std::locale());
203+
}
204+
195205
template <typename Target>
196-
Target scan_string(const utility::string_t &str)
206+
Target scan_string(const utility::string_t &str, const std::locale &loc)
197207
{
198208
Target t;
199209
utility::istringstream_t iss(str);
210+
iss.imbue(loc);
200211
iss >> t;
201212
if (iss.bad())
213+
{
202214
throw std::bad_cast();
215+
}
203216
return t;
204217
}
218+
219+
template <typename Target>
220+
Target scan_string(const utility::string_t &str)
221+
{
222+
return scan_string<Target>(str, std::locale());
223+
}
205224
}
206225

207226
namespace details

Release/include/cpprest/details/SafeInt3.hpp

Lines changed: 1139 additions & 1032 deletions
Large diffs are not rendered by default.

Release/include/cpprest/details/http_server_asio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class hostport_listener
136136
m_all_connections_complete.set();
137137

138138
std::istringstream hostport_in(hostport);
139+
hostport_in.imbue(std::locale::classic());
139140

140141
std::getline(hostport_in, m_host, ':');
141142
std::getline(hostport_in, m_port);

Release/include/cpprest/http_headers.h

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace web { namespace http {
4040
/// <param name="ref">The value to bind to.</param>
4141
/// <returns><c>true</c> if the binding succeeds, <c>false</c> otherwise.</returns>
4242
template<typename key_type, typename _t>
43+
CASABLANCA_DEPRECATED("This API is deprecated and will be removed in a future release, std::istringstream instead.")
4344
bool bind(const key_type &text, _t &ref) // const
4445
{
4546
utility::istringstream_t iss(text);
@@ -61,6 +62,7 @@ bool bind(const key_type &text, _t &ref) // const
6162
/// <param name="ref">The value to bind to.</param>
6263
/// <returns><c>true</c> if the binding succeeds, <c>false</c> otherwise.</returns>
6364
template <typename key_type>
65+
CASABLANCA_DEPRECATED("This API is deprecated and will be removed in a future release.")
6466
bool bind(const key_type &text, utility::string_t &ref) //const
6567
{
6668
ref = text;
@@ -175,7 +177,7 @@ class http_headers
175177
}
176178

177179
/// <summary>
178-
/// Removes all elements from the hearders
180+
/// Removes all elements from the headers.
179181
/// </summary>
180182
void clear() { m_headers.clear(); }
181183

@@ -227,10 +229,10 @@ class http_headers
227229
// Check to see if doesn't have a value.
228230
if(iter->second.empty())
229231
{
230-
http::bind(iter->second, value);
232+
bind_impl(iter->second, value);
231233
return true;
232234
}
233-
return http::bind(iter->second, value);
235+
return bind_impl(iter->second, value);
234236
}
235237
else
236238
{
@@ -239,7 +241,7 @@ class http_headers
239241
}
240242

241243
/// <summary>
242-
/// Returns an iterator refering to the first header field.
244+
/// Returns an iterator referring to the first header field.
243245
/// </summary>
244246
/// <returns>An iterator to the beginning of the HTTP headers</returns>
245247
iterator begin() { return m_headers.begin(); }
@@ -248,7 +250,7 @@ class http_headers
248250
/// <summary>
249251
/// Returns an iterator referring to the past-the-end header field.
250252
/// </summary>
251-
/// <returns>An iterator to the element past the end of the HTTP headers</returns>
253+
/// <returns>An iterator to the element past the end of the HTTP headers.</returns>
252254
iterator end() { return m_headers.end(); }
253255
const_iterator end() const { return m_headers.end(); }
254256

@@ -302,6 +304,26 @@ class http_headers
302304

303305
private:
304306

307+
template<typename _t>
308+
bool bind_impl(const key_type &text, _t &ref) const
309+
{
310+
utility::istringstream_t iss(text);
311+
iss.imbue(std::locale::classic());
312+
iss >> ref;
313+
if (iss.fail() || !iss.eof())
314+
{
315+
return false;
316+
}
317+
318+
return true;
319+
}
320+
321+
bool bind_impl(const key_type &text, ::utility::string_t &ref) const
322+
{
323+
ref = text;
324+
return true;
325+
}
326+
305327
// Headers are stored in a map with case insensitive key.
306328
std::map<utility::string_t, utility::string_t, _case_insensitive_cmp> m_headers;
307329
};

Release/include/cpprest/http_listener.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class http_listener
250250
/// Add a general handler to support all requests.
251251
/// </summary>
252252
/// <param name="handler">Function object to be called for all requests.</param>
253-
void support(std::function<void(http_request)> handler)
253+
void support(const std::function<void(http_request)> &handler)
254254
{
255255
m_impl->m_all_requests = handler;
256256
}
@@ -260,7 +260,7 @@ class http_listener
260260
/// </summary>
261261
/// <param name="method">An HTTP method.</param>
262262
/// <param name="handler">Function object to be called for all requests for the given HTTP method.</param>
263-
void support(const http::method &method, std::function<void(http_request)> handler)
263+
void support(const http::method &method, const std::function<void(http_request)> &handler)
264264
{
265265
m_impl->m_supported_methods[method] = handler;
266266
}

Release/include/cpprest/oauth1.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,7 @@ class oauth1_config
505505

506506
static utility::string_t _generate_timestamp()
507507
{
508-
utility::ostringstream_t os;
509-
os << utility::datetime::utc_timestamp();
510-
return os.str();
508+
return utility::conversions::print_string(utility::datetime::utc_timestamp(), std::locale::classic());
511509
}
512510

513511
_ASYNCRTIMP static std::vector<unsigned char> __cdecl _hmac_sha1(const utility::string_t& key, const utility::string_t& data);

Release/include/cpprest/uri_builder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ namespace web
237237
uri_builder &append_query(utility::string_t name, const T &value, bool do_encoding = true)
238238
{
239239
utility::ostringstream_t ss;
240+
ss.imbue(std::locale::classic());
240241
ss << name << _XPLATSTR("=") << value;
241242
return append_query(ss.str(), do_encoding);
242243
}

Release/include/pplx/threadpool.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,9 @@ class threadpool
7272
for (size_t i = 0; i < n; i++)
7373
add_thread();
7474
}
75-
#if defined(__ANDROID__)
75+
7676
static threadpool& shared_instance();
77-
#else
78-
static threadpool& shared_instance()
79-
{
80-
return s_shared;
81-
}
82-
#endif
77+
8378
~threadpool()
8479
{
8580
m_service.stop();
@@ -105,10 +100,6 @@ class threadpool
105100
private:
106101
struct _cancel_thread { };
107102

108-
#if !defined(__ANDROID__)
109-
static threadpool s_shared;
110-
#endif
111-
112103
void add_thread()
113104
{
114105
pthread_t t;

Release/libs/websocketpp/websocketpp/transport/asio/connection.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ class connection : public config::socket_type::socket_con_type {
442442
if (ec) {
443443
// reset the handlers to break the circular reference:
444444
// this->handler->this
445-
m_async_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
446-
m_async_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
445+
m_async_read_handler = async_read_handler();
446+
m_async_write_handler = async_write_handler();
447447
}
448448

449449
return ec;
@@ -969,12 +969,12 @@ class connection : public config::socket_type::socket_con_type {
969969
// Reset cached handlers now that we won't be reading or writing anymore
970970
// These cached handlers store shared pointers to this connection and
971971
// will leak the connection if not destroyed.
972-
m_async_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
973-
m_async_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
974-
m_init_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
972+
m_async_read_handler = async_read_handler();
973+
m_async_write_handler = async_write_handler();
974+
m_init_handler = init_handler();
975975

976-
m_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
977-
m_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
976+
m_read_handler = read_handler();
977+
m_write_handler = write_handler();
978978

979979
timer_ptr shutdown_timer;
980980
shutdown_timer = set_timer(

0 commit comments

Comments
 (0)