Skip to content

Commit 570643d

Browse files
unknownunknown
authored andcommitted
Some corrections and merges
Signed-off-by: unknown <[email protected]>
1 parent 75ad3e1 commit 570643d

File tree

7 files changed

+93
-39
lines changed

7 files changed

+93
-39
lines changed

Release/casablanca110.sln

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Uri110_test", "tests\Functi
2727
EndProject
2828
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "casablanca110.winrt", "src\build\casablanca110.winrt.vcxproj", "{198ED804-2655-4D92-8104-C220E3EA9452}"
2929
EndProject
30+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HttpListener110_test", "tests\Functional\http\listener\VS11\HttpListener110_test.vcxproj", "{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}"
31+
EndProject
3032
Global
3133
GlobalSection(TeamFoundationVersionControl) = preSolution
3234
SccNumberOfProjects = 14
@@ -92,15 +94,15 @@ Global
9294
SccAuxPath11 = http://tkbgitvstfat01:8080/devdiv2
9395
SccLocalPath11 = tests\\Functional\\uri\\VS11
9496
SccProvider11 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
95-
SccProjectUniqueName12 = tests\\Functional\\http\\utilities\\testlistener\\VS11\\testlistener110.vcxproj
96-
SccProjectName12 = tests/Functional/http/utilities/testlistener/VS11
97+
SccProjectUniqueName12 = src\\build\\casablanca110.winrt.vcxproj
98+
SccProjectName12 = src/build
9799
SccAuxPath12 = http://tkbgitvstfat01:8080/devdiv2
98-
SccLocalPath12 = tests\\Functional\\http\\utilities\\testlistener\\VS11
100+
SccLocalPath12 = src\\build
99101
SccProvider12 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
100-
SccProjectUniqueName13 = src\\build\\casablanca110.winrt.vcxproj
101-
SccProjectName13 = src/build
102+
SccProjectUniqueName13 = tests\\Functional\\http\\listener\\VS11\\HttpListener110_test.vcxproj
103+
SccProjectName13 = tests/Functional/http/listener/VS11
102104
SccAuxPath13 = http://tkbgitvstfat01:8080/devdiv2
103-
SccLocalPath13 = src\\build
105+
SccLocalPath13 = tests\\Functional\\http\\listener\\VS11
104106
SccProvider13 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
105107
EndGlobalSection
106108
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -266,6 +268,18 @@ Global
266268
{198ED804-2655-4D92-8104-C220E3EA9452}.Release|Win32.Build.0 = Release|Win32
267269
{198ED804-2655-4D92-8104-C220E3EA9452}.Release|x64.ActiveCfg = Release|x64
268270
{198ED804-2655-4D92-8104-C220E3EA9452}.Release|x64.Build.0 = Release|x64
271+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Debug|ARM.ActiveCfg = Debug|ARM
272+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Debug|ARM.Build.0 = Debug|ARM
273+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Debug|Win32.ActiveCfg = Debug|Win32
274+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Debug|Win32.Build.0 = Debug|Win32
275+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Debug|x64.ActiveCfg = Debug|x64
276+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Debug|x64.Build.0 = Debug|x64
277+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Release|ARM.ActiveCfg = Release|ARM
278+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Release|ARM.Build.0 = Release|ARM
279+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Release|Win32.ActiveCfg = Release|Win32
280+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Release|Win32.Build.0 = Release|Win32
281+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Release|x64.ActiveCfg = Release|x64
282+
{2853EC0B-1B8E-4D9D-8436-4EF6DDED5378}.Release|x64.Build.0 = Release|x64
269283
EndGlobalSection
270284
GlobalSection(SolutionProperties) = preSolution
271285
HideSolutionNode = FALSE

Release/include/cpprest/http_client_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ using namespace concurrency;
4444
#else
4545
#include <boost/asio.hpp>
4646
#include <boost/bind.hpp>
47+
#ifndef __APPLE__
4748
#include <boost/asio/ssl.hpp>
49+
#endif
4850
#include <boost/algorithm/string.hpp>
4951
#include <pplx/threadpool.h>
5052
#endif

Release/include/cpprest/http_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ namespace details
134134
//
135135
// There are up to 12 additional bytes needed for each chunk:
136136
//
137-
// The last chunk requires 7 bytes, and is fixed.
137+
// The last chunk requires 5 bytes, and is fixed.
138138
// All other chunks require up to 8 bytes for the length, and four for the two CRLF
139139
// delimiters.
140140
//

Release/src/dirs.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
<ItemGroup Condition="'$(DevToolsVersion)'=='120'">
2323
<ProjectFile Include="build\casablanca120.vcxproj" Condition="'$(Platform)'!='ARM' or '$(WindowsSDKDesktopARMSupport)' == 'true'" />
24+
<ProjectFile Include="build\casablanca120.xp.vcxproj" Condition="'$(Platform)'!='ARM'" />
2425
</ItemGroup>
2526

2627
<ItemGroup Condition="'$(OsVersion)|$(DevToolsVersion)'=='6.2|120' or '$(OsVersion)|$(DevToolsVersion)'=='6.3|120'">

Release/src/http/client/http_linux.cpp

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ namespace web { namespace http
8787
}
8888

8989
std::unique_ptr<tcp::socket> m_socket;
90+
#ifndef __APPLE__
9091
std::unique_ptr<boost::asio::ssl::stream<tcp::socket>> m_ssl_stream;
91-
92+
#endif
9293
uri m_what;
9394
size_t m_known_size;
9495
size_t m_current_size;
@@ -120,18 +121,21 @@ namespace web { namespace http
120121
m_socket.reset();
121122
}
122123

124+
#ifndef __APPLE__
123125
if (m_ssl_stream)
124126
{
125127
shutdown_socket(m_ssl_stream->lowest_layer());
126128
m_ssl_stream.reset();
127129
}
130+
#endif
128131
}
129132

130133
void cancel(const boost::system::error_code& ec)
131134
{
132135
if (!ec)
133136
{
134137
m_timedout = true;
138+
#ifndef __APPLE__
135139
if (m_ssl_stream)
136140
{
137141
boost::system::error_code error;
@@ -141,6 +145,7 @@ namespace web { namespace http
141145
report_error("Failed to cancel the socket", error);
142146
}
143147
else
148+
#endif
144149
{
145150
auto sock = m_socket.get();
146151
if (sock != nullptr)
@@ -182,9 +187,14 @@ namespace web { namespace http
182187

183188
if (what.scheme() == "https")
184189
{
190+
#ifndef __APPLE__
185191
boost::asio::ssl::context context(boost::asio::ssl::context::sslv23);
186192
context.set_default_verify_paths();
187193
ctx->m_ssl_stream.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(m_io_service, context));
194+
#else
195+
ctx->report_exception(http_exception("https is not supported"));
196+
return;
197+
#endif
188198
}
189199
else
190200
ctx->m_socket.reset(new tcp::socket(m_io_service));
@@ -208,8 +218,14 @@ namespace web { namespace http
208218
request_stream << method << " " << resource << " " << "HTTP/1.1" << CRLF << "Host: " << host;
209219

210220
int port = what.port();
211-
if (port == 0)
221+
if (what.is_port_default())
222+
{
223+
#ifndef __APPLE__
212224
port = (ctx->m_ssl_stream ? 443 : 80);
225+
#else
226+
port = 80;
227+
#endif
228+
}
213229
request_stream << ":" << port << CRLF;
214230

215231
// Check user specified transfer-encoding
@@ -243,7 +259,9 @@ namespace web { namespace http
243259

244260
request_stream << flatten_http_headers(ctx->m_request.headers());
245261

262+
#ifndef __APPLE__
246263
if (!ctx->m_ssl_stream)
264+
#endif
247265
request_stream << "Connection: close" << CRLF; // so we can just read to EOF
248266

249267
request_stream << CRLF;
@@ -290,6 +308,7 @@ namespace web { namespace http
290308
else
291309
{
292310
auto endpoint = *endpoints;
311+
#ifndef __APPLE__
293312
if (ctx->m_ssl_stream)
294313
{
295314
// Check to turn off server certificate verification.
@@ -306,6 +325,7 @@ namespace web { namespace http
306325
ctx->m_ssl_stream->lowest_layer().async_connect(endpoint, boost::bind(&client::handle_connect, this, boost::asio::placeholders::error, ++endpoints, ctx));
307326
}
308327
else
328+
#endif
309329
ctx->m_socket->async_connect(endpoint, boost::bind(&client::handle_connect, this, boost::asio::placeholders::error, ++endpoints, ctx));
310330
}
311331
}
@@ -314,9 +334,11 @@ namespace web { namespace http
314334
{
315335
if (!ec)
316336
{
337+
#ifndef __APPLE__
317338
if (ctx->m_ssl_stream)
318339
ctx->m_ssl_stream->async_handshake(boost::asio::ssl::stream_base::client, boost::bind(&client::handle_handshake, this, boost::asio::placeholders::error, ctx));
319340
else
341+
#endif
320342
boost::asio::async_write(*ctx->m_socket, ctx->m_request_buf, boost::bind(&client::handle_write_request, this, boost::asio::placeholders::error, ctx));
321343
}
322344
else if (endpoints == tcp::resolver::iterator())
@@ -327,6 +349,7 @@ namespace web { namespace http
327349
{
328350
boost::system::error_code ignore;
329351
auto endpoint = *endpoints;
352+
#ifndef __APPLE__
330353
if (ctx->m_ssl_stream)
331354
{
332355
ctx->m_ssl_stream->lowest_layer().shutdown(tcp::socket::shutdown_both, ignore);
@@ -350,6 +373,7 @@ namespace web { namespace http
350373
ctx->m_ssl_stream->lowest_layer().async_connect(endpoint, boost::bind(&client::handle_connect, this, boost::asio::placeholders::error, ++endpoints, ctx));
351374
}
352375
else
376+
#endif
353377
{
354378
ctx->m_socket->shutdown(tcp::socket::shutdown_both, ignore);
355379
ctx->m_socket->close();
@@ -359,14 +383,15 @@ namespace web { namespace http
359383
}
360384
}
361385

386+
#ifndef __APPLE__
362387
void handle_handshake(const boost::system::error_code& ec, linux_request_context* ctx)
363388
{
364389
if (!ec)
365390
boost::asio::async_write(*ctx->m_ssl_stream, ctx->m_request_buf, boost::bind(&client::handle_write_request, this, boost::asio::placeholders::error, ctx));
366391
else
367392
ctx->report_error("Error code in handle_handshake is ", ec, httpclient_errorcode_context::handshake);
368393
}
369-
394+
#endif
370395
void handle_write_chunked_body(const boost::system::error_code& ec, linux_request_context* ctx)
371396
{
372397
if (ec)
@@ -394,10 +419,12 @@ namespace web { namespace http
394419
ctx->m_request_buf.consume(offset);
395420
ctx->m_current_size += readSize;
396421
ctx->m_uploaded += (size64_t)readSize;
422+
#ifndef __APPLE__
397423
if (ctx->m_ssl_stream)
398424
boost::asio::async_write(*ctx->m_ssl_stream, ctx->m_request_buf,
399425
boost::bind(readSize != 0 ? &client::handle_write_chunked_body : &client::handle_write_body, this, boost::asio::placeholders::error, ctx));
400426
else
427+
#endif
401428
boost::asio::async_write(*ctx->m_socket, ctx->m_request_buf,
402429
boost::bind(readSize != 0 ? &client::handle_write_chunked_body : &client::handle_write_body, this, boost::asio::placeholders::error, ctx));
403430
});
@@ -431,10 +458,12 @@ namespace web { namespace http
431458
ctx->m_uploaded += (size64_t)actualSize;
432459
ctx->m_current_size += actualSize;
433460
ctx->m_request_buf.commit(actualSize);
461+
#ifndef __APPLE__
434462
if (ctx->m_ssl_stream)
435463
boost::asio::async_write(*ctx->m_ssl_stream, ctx->m_request_buf,
436464
boost::bind(&client::handle_write_large_body, this, boost::asio::placeholders::error, ctx));
437465
else
466+
#endif
438467
boost::asio::async_write(*ctx->m_socket, ctx->m_request_buf,
439468
boost::bind(&client::handle_write_large_body, this, boost::asio::placeholders::error, ctx));
440469
});
@@ -468,10 +497,12 @@ namespace web { namespace http
468497
}
469498

470499
// Read until the end of entire headers
500+
#ifndef __APPLE__
471501
if (ctx->m_ssl_stream)
472502
boost::asio::async_read_until(*ctx->m_ssl_stream, ctx->m_response_buf, CRLF+CRLF,
473503
boost::bind(&client::handle_status_line, this, boost::asio::placeholders::error, ctx));
474504
else
505+
#endif
475506
boost::asio::async_read_until(*ctx->m_socket, ctx->m_response_buf, CRLF+CRLF,
476507
boost::bind(&client::handle_status_line, this, boost::asio::placeholders::error, ctx));
477508
}
@@ -562,10 +593,12 @@ namespace web { namespace http
562593
boost::bind(&client::handle_read_content, this, boost::asio::placeholders::error, ctx), ctx);
563594
else
564595
{
596+
#ifndef __APPLE__
565597
if (ctx->m_ssl_stream)
566598
boost::asio::async_read_until(*ctx->m_ssl_stream, ctx->m_response_buf, CRLF,
567599
boost::bind(&client::handle_chunk_header, this, boost::asio::placeholders::error, ctx));
568600
else
601+
#endif
569602
boost::asio::async_read_until(*ctx->m_socket, ctx->m_response_buf, CRLF,
570603
boost::bind(&client::handle_chunk_header, this, boost::asio::placeholders::error, ctx));
571604
}
@@ -576,13 +609,15 @@ namespace web { namespace http
576609
void async_read_until_buffersize(size_t size, ReadHandler handler, linux_request_context* ctx)
577610
{
578611
size_t size_to_read = 0;
612+
#ifndef __APPLE__
579613
if (ctx->m_ssl_stream)
580614
{
581615
if (ctx->m_response_buf.size() < size)
582616
size_to_read = size - ctx->m_response_buf.size();
583617
boost::asio::async_read(*ctx->m_ssl_stream, ctx->m_response_buf, boost::asio::transfer_at_least(size_to_read), handler);
584618
}
585619
else
620+
#endif
586621
{
587622
if (ctx->m_response_buf.size() < size)
588623
size_to_read = size - ctx->m_response_buf.size();
@@ -656,10 +691,12 @@ namespace web { namespace http
656691
}
657692
ctx->m_response_buf.consume(to_read + CRLF.size()); // consume crlf
658693

694+
#ifndef __APPLE__
659695
if (ctx->m_ssl_stream)
660696
boost::asio::async_read_until(*ctx->m_ssl_stream, ctx->m_response_buf, CRLF,
661697
boost::bind(&client::handle_chunk_header, this, boost::asio::placeholders::error, ctx));
662698
else
699+
#endif
663700
boost::asio::async_read_until(*ctx->m_socket, ctx->m_response_buf, CRLF,
664701
boost::bind(&client::handle_chunk_header, this, boost::asio::placeholders::error, ctx));
665702
});
@@ -677,13 +714,13 @@ namespace web { namespace http
677714

678715
if (ec)
679716
{
680-
if (ec == boost::asio::error::eof && ctx->m_known_size == std::numeric_limits<size_t>::max())
681-
ctx->m_known_size = ctx->m_current_size + ctx->m_response_buf.size();
682-
else
683-
{
684-
ctx->report_error("Failed to read response body", ec, httpclient_errorcode_context::readbody);
685-
return;
686-
}
717+
if (ec == boost::asio::error::eof && ctx->m_known_size == std::numeric_limits<size_t>::max())
718+
ctx->m_known_size = ctx->m_current_size + ctx->m_response_buf.size();
719+
else
720+
{
721+
ctx->report_error("Failed to read response body", ec, httpclient_errorcode_context::readbody);
722+
return;
723+
}
687724
}
688725
auto progress = ctx->m_request._get_impl()->_progress_handler();
689726
if ( progress )

Release/src/http/common/http_helpers.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,9 @@ size_t chunked_encoding::add_chunked_delimiters(_Out_writes_ (buffer_size) uint8
515515

516516
if ( bytes_read == 0 )
517517
{
518-
offset = 5;
519-
data[5] = '0';
520-
data[6] = '\r'; data[7] = '\n'; // The end of the size.
521-
data[8] = '\r'; data[9] = '\n'; // The end of the (empty) trailer.
518+
offset = 7;
519+
data[7] = '0';
520+
data[8] = '\r'; data[9] = '\n'; // The end of the size.
522521
data[10] = '\r'; data[11] = '\n'; // The end of the message.
523522
}
524523
else

0 commit comments

Comments
 (0)