Skip to content

Commit 09714d9

Browse files
author
Benjamin Lee
committed
Various fixes on microsoft#866 which broke building for iOS and Mac
1 parent 74da372 commit 09714d9

File tree

5 files changed

+77
-77
lines changed

5 files changed

+77
-77
lines changed

Release/include/cpprest/http_compression.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class decompress_factory
9696
{
9797
public:
9898
virtual const utility::string_t& algorithm() const = 0;
99-
virtual const uint16_t weight() const = 0;
99+
virtual uint16_t weight() const = 0;
100100
virtual std::unique_ptr<decompress_provider> make_decompressor() const = 0;
101101
virtual ~decompress_factory() = default;
102102
};
@@ -117,9 +117,9 @@ _ASYNCRTIMP bool supported();
117117
/// </summary>
118118
namespace algorithm
119119
{
120-
constexpr utility::char_t *GZIP = _XPLATSTR("gzip");
121-
constexpr utility::char_t *DEFLATE = _XPLATSTR("deflate");
122-
constexpr utility::char_t *BROTLI = _XPLATSTR("br");
120+
constexpr utility::char_t *GZIP = const_cast<utility::char_t *>(_XPLATSTR("gzip"));
121+
constexpr utility::char_t *DEFLATE = const_cast<utility::char_t *>(_XPLATSTR("deflate"));
122+
constexpr utility::char_t *BROTLI = const_cast<utility::char_t *>(_XPLATSTR("br"));
123123

124124
/// <summary>
125125
/// Test whether cpprestsdk was built with built-in compression support and

Release/include/cpprest/http_headers.h

+32-32
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,37 @@
1818
#include "cpprest/asyncrt_utils.h"
1919

2020
namespace web { namespace http {
21-
21+
namespace details
22+
{
23+
template<typename key_type, typename _t>
24+
bool bind_impl(const key_type &text, _t &ref)
25+
{
26+
utility::istringstream_t iss(text);
27+
iss.imbue(std::locale::classic());
28+
iss >> ref;
29+
if (iss.fail() || !iss.eof())
30+
{
31+
return false;
32+
}
33+
34+
return true;
35+
}
36+
37+
template<typename key_type>
38+
bool bind_impl(const key_type &text, utf16string &ref)
39+
{
40+
ref = utility::conversions::to_utf16string(text);
41+
return true;
42+
}
43+
44+
template<typename key_type>
45+
bool bind_impl(const key_type &text, std::string &ref)
46+
{
47+
ref = utility::conversions::to_utf8string(text);
48+
return true;
49+
}
50+
}
51+
2252
/// <summary>
2353
/// Binds an individual reference to a string value.
2454
/// </summary>
@@ -219,7 +249,7 @@ class http_headers
219249
return false;
220250
}
221251

222-
return details::bind_impl(iter->second, value) || iter->second.empty();
252+
return web::http::details::bind_impl(iter->second, value) || iter->second.empty();
223253
}
224254

225255
/// <summary>
@@ -289,34 +319,4 @@ class http_headers
289319
inner_container m_headers;
290320
};
291321

292-
namespace details
293-
{
294-
template<typename key_type, typename _t>
295-
bool bind_impl(const key_type &text, _t &ref)
296-
{
297-
utility::istringstream_t iss(text);
298-
iss.imbue(std::locale::classic());
299-
iss >> ref;
300-
if (iss.fail() || !iss.eof())
301-
{
302-
return false;
303-
}
304-
305-
return true;
306-
}
307-
308-
template<typename key_type>
309-
bool bind_impl(const key_type &text, utf16string &ref)
310-
{
311-
ref = utility::conversions::to_utf16string(text);
312-
return true;
313-
}
314-
315-
template<typename key_type>
316-
bool bind_impl(const key_type &text, std::string &ref)
317-
{
318-
ref = utility::conversions::to_utf8string(text);
319-
return true;
320-
}
321-
}
322322
}}

Release/src/http/common/http_compression.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class zlib_compressor_base : public compress_provider
156156

157157
private:
158158
int m_state{Z_BUF_ERROR};
159-
z_stream m_stream{0};
159+
z_stream m_stream{};
160160
const utility::string_t& m_algorithm;
161161
};
162162

@@ -263,7 +263,7 @@ class zlib_decompressor_base : public decompress_provider
263263

264264
private:
265265
int m_state{Z_BUF_ERROR};
266-
z_stream m_stream{0};
266+
z_stream m_stream{};
267267
const utility::string_t& m_algorithm;
268268
};
269269

@@ -283,7 +283,7 @@ class gzip_compressor : public zlib_compressor_base
283283
class gzip_decompressor : public zlib_decompressor_base
284284
{
285285
public:
286-
gzip_decompressor::gzip_decompressor() : zlib_decompressor_base(16) // gzip auto-detect
286+
gzip_decompressor() : zlib_decompressor_base(16) // gzip auto-detect
287287
{
288288
}
289289
};
@@ -620,7 +620,7 @@ class generic_decompress_factory : public decompress_factory
620620

621621
const utility::string_t& algorithm() const { return m_algorithm; }
622622

623-
const uint16_t weight() const { return m_weight; }
623+
uint16_t weight() const { return m_weight; }
624624

625625
std::unique_ptr<decompress_provider> make_decompressor() const { return _make_decompressor(); }
626626

@@ -634,14 +634,14 @@ class generic_decompress_factory : public decompress_factory
634634
static const std::vector<std::shared_ptr<compress_factory>> g_compress_factories
635635
#if defined(CPPREST_HTTP_COMPRESSION)
636636
= {std::make_shared<generic_compress_factory>(
637-
algorithm::GZIP, []() -> std::unique_ptr<compress_provider> { return std::make_unique<gzip_compressor>(); }),
637+
algorithm::GZIP, []() -> std::unique_ptr<compress_provider> { return utility::details::make_unique<gzip_compressor>(); }),
638638
std::make_shared<generic_compress_factory>(
639639
algorithm::DEFLATE,
640-
[]() -> std::unique_ptr<compress_provider> { return std::make_unique<deflate_compressor>(); }),
640+
[]() -> std::unique_ptr<compress_provider> { return utility::details::make_unique<deflate_compressor>(); }),
641641
#if defined(CPPREST_BROTLI_COMPRESSION)
642642
std::make_shared<generic_compress_factory>(
643643
algorithm::BROTLI,
644-
[]() -> std::unique_ptr<compress_provider> { return std::make_unique<brotli_compressor>(); })
644+
[]() -> std::unique_ptr<compress_provider> { return utility::details::make_unique<brotli_compressor>(); })
645645
#endif // CPPREST_BROTLI_COMPRESSION
646646
};
647647
#else // CPPREST_HTTP_COMPRESSION
@@ -653,16 +653,16 @@ static const std::vector<std::shared_ptr<decompress_factory>> g_decompress_facto
653653
= {std::make_shared<generic_decompress_factory>(
654654
algorithm::GZIP,
655655
500,
656-
[]() -> std::unique_ptr<decompress_provider> { return std::make_unique<gzip_decompressor>(); }),
656+
[]() -> std::unique_ptr<decompress_provider> { return utility::details::make_unique<gzip_decompressor>(); }),
657657
std::make_shared<generic_decompress_factory>(
658658
algorithm::DEFLATE,
659659
500,
660-
[]() -> std::unique_ptr<decompress_provider> { return std::make_unique<deflate_decompressor>(); }),
660+
[]() -> std::unique_ptr<decompress_provider> { return utility::details::make_unique<deflate_decompressor>(); }),
661661
#if defined(CPPREST_BROTLI_COMPRESSION)
662662
std::make_shared<generic_decompress_factory>(
663663
algorithm::BROTLI,
664664
500,
665-
[]() -> std::unique_ptr<decompress_provider> { return std::make_unique<brotli_decompressor>(); })
665+
[]() -> std::unique_ptr<decompress_provider> { return utility::details::make_unique<brotli_decompressor>(); })
666666
#endif // CPPREST_BROTLI_COMPRESSION
667667
};
668668
#else // CPPREST_HTTP_COMPRESSION
@@ -751,7 +751,7 @@ std::shared_ptr<decompress_factory> get_decompress_factory(const utility::string
751751
std::unique_ptr<compress_provider> make_gzip_compressor(int compressionLevel, int method, int strategy, int memLevel)
752752
{
753753
#if defined(CPPREST_HTTP_COMPRESSION)
754-
return std::move(std::make_unique<gzip_compressor>(compressionLevel, method, strategy, memLevel));
754+
return utility::details::make_unique<gzip_compressor>(compressionLevel, method, strategy, memLevel);
755755
#else // CPPREST_HTTP_COMPRESSION
756756
return std::unique_ptr<compress_provider>();
757757
#endif // CPPREST_HTTP_COMPRESSION
@@ -760,7 +760,7 @@ std::unique_ptr<compress_provider> make_gzip_compressor(int compressionLevel, in
760760
std::unique_ptr<compress_provider> make_deflate_compressor(int compressionLevel, int method, int strategy, int memLevel)
761761
{
762762
#if defined(CPPREST_HTTP_COMPRESSION)
763-
return std::move(std::make_unique<deflate_compressor>(compressionLevel, method, strategy, memLevel));
763+
return utility::details::make_unique<deflate_compressor>(compressionLevel, method, strategy, memLevel);
764764
#else // CPPREST_HTTP_COMPRESSION
765765
return std::unique_ptr<compress_provider>();
766766
#endif // CPPREST_HTTP_COMPRESSION
@@ -769,7 +769,7 @@ std::unique_ptr<compress_provider> make_deflate_compressor(int compressionLevel,
769769
std::unique_ptr<compress_provider> make_brotli_compressor(uint32_t window, uint32_t quality, uint32_t mode)
770770
{
771771
#if defined(CPPREST_HTTP_COMPRESSION) && defined(CPPREST_BROTLI_COMPRESSION)
772-
return std::move(std::make_unique<brotli_compressor>(window, quality, mode));
772+
return utility::details::make_unique<brotli_compressor>(window, quality, mode);
773773
#else // CPPREST_BROTLI_COMPRESSION
774774
return std::unique_ptr<compress_provider>();
775775
#endif // CPPREST_BROTLI_COMPRESSION
@@ -951,7 +951,7 @@ std::unique_ptr<compress_provider> get_compressor_from_header(
951951

952952
if (compressor)
953953
{
954-
return std::move(compressor);
954+
return compressor;
955955
}
956956

957957
// If we're here, we didn't match the caller's compressor above;
@@ -965,7 +965,7 @@ std::unique_ptr<compress_provider> get_compressor_from_header(
965965
auto compressor = web::http::compression::builtin::_make_compressor(f, coding);
966966
if (compressor)
967967
{
968-
return std::move(compressor);
968+
return compressor;
969969
}
970970
if (type == header_types::accept_encoding && utility::details::str_iequal(coding, _XPLATSTR("identity")))
971971
{
@@ -1068,7 +1068,7 @@ std::unique_ptr<decompress_provider> get_decompressor_from_header(
10681068

10691069
// Either the response is compressed and we have a decompressor that can handle it, or
10701070
// built-in compression is not enabled and we don't have an alternate set of decompressors
1071-
return std::move(decompressor);
1071+
return decompressor;
10721072
}
10731073

10741074
utility::string_t build_supported_header(header_types type,
@@ -1084,7 +1084,7 @@ utility::string_t build_supported_header(header_types type,
10841084
// Add all specified algorithms and their weights to the header
10851085
start = true;
10861086
os.imbue(std::locale::classic());
1087-
for each (auto& factory in f)
1087+
for (auto& factory : f)
10881088
{
10891089
if (factory)
10901090
{
@@ -1109,7 +1109,7 @@ utility::string_t build_supported_header(header_types type,
11091109
os << _XPLATSTR("identity;q=1, *;q=0");
11101110
}
11111111

1112-
return std::move(os.str());
1112+
return os.str();
11131113
}
11141114
} // namespace details
11151115
} // namespace compression

Release/src/http/common/internal_http_helpers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool validate_method(const utility::string_t& method);
3434

3535
namespace web { namespace http { namespace compression {
3636

37-
class compression::decompress_factory;
37+
class decompress_factory;
3838

3939
namespace details { namespace builtin {
4040

0 commit comments

Comments
 (0)