Skip to content

Commit 86e9dd3

Browse files
committed
Moved trim_whitespace and get_default_reason_phrase to be internal.
1 parent aa12424 commit 86e9dd3

File tree

16 files changed

+60
-32
lines changed

16 files changed

+60
-32
lines changed

Release/include/cpprest/details/http_helpers.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ namespace web { namespace http
2424
namespace details
2525
{
2626

27-
/// <summary>
28-
/// Helper function to get the default HTTP reason phrase for a status code.
29-
/// </summary>
30-
utility::string_t get_default_reason_phrase(status_code code);
31-
32-
// simple helper functions to trim whitespace.
33-
_ASYNCRTIMP void __cdecl trim_whitespace(utility::string_t &str);
34-
35-
bool validate_method(const utility::string_t& method);
36-
3727
namespace chunked_encoding
3828
{
3929
// Transfer-Encoding: chunked support

Release/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(SOURCES
1616
http/client/http_client_msg.cpp
1717
http/client/http_client_impl.h
1818
http/client/x509_cert_utilities.cpp
19+
http/common/internal_http_helpers.h
1920
http/common/http_helpers.cpp
2021
http/common/http_msg.cpp
2122
http/listener/http_listener.cpp

Release/src/build/common.vcxitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\pplx\pplxinterface.h" />
8585
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\pplx\pplxtasks.h" />
8686
<ClInclude Include="$(MSBuildThisFileDirectory)..\http\client\http_client_impl.h" />
87+
<ClInclude Include="$(MSBuildThisFileDirectory)..\http\common\internal_http_helpers.h" />
8788
<ClInclude Include="$(MSBuildThisFileDirectory)..\pch\stdafx.h" />
8889
</ItemGroup>
8990
<ItemGroup>

Release/src/build/common.vcxitems.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
<ClInclude Include="$(MSBuildThisFileDirectory)..\http\client\http_client_impl.h">
216216
<Filter>Header Files\private</Filter>
217217
</ClInclude>
218+
<ClInclude Include="$(MSBuildThisFileDirectory)..\http\common\internal_http_helpers.h" />
218219
</ItemGroup>
219220
<ItemGroup>
220221
<None Include="$(MSBuildThisFileDirectory)..\..\include\cpprest\details\http_constants.dat">

Release/src/http/client/http_client_asio.cpp

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

1616
#include "stdafx.h"
1717

18+
#include "../common/internal_http_helpers.h"
1819
#if defined(__clang__)
1920
#pragma clang diagnostic push
2021
#pragma clang diagnostic ignored "-Wunused-local-typedef"

Release/src/http/client/http_client_msg.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1212
****/
1313
#include "stdafx.h"
14+
#include "../common/internal_http_helpers.h"
1415

1516
namespace web { namespace http
1617
{

Release/src/http/client/http_client_winrt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "stdafx.h"
1616

1717
#include "http_client_impl.h"
18+
#include "../common/internal_http_helpers.h"
1819

1920
#include <Strsafe.h>
2021
// Important for WP8

Release/src/http/common/http_helpers.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <zlib.h>
3434
#endif
3535

36+
#include "internal_http_helpers.h"
37+
3638
using namespace web;
3739
using namespace utility;
3840
using namespace utility::conversions;
@@ -79,24 +81,6 @@ utility::string_t get_default_reason_phrase(status_code code)
7981
return phrase;
8082
}
8183

82-
static void ltrim_whitespace(utility::string_t &str)
83-
{
84-
size_t index;
85-
for (index = 0; index < str.size() && isspace(str[index]); ++index);
86-
str.erase(0, index);
87-
}
88-
static void rtrim_whitespace(utility::string_t &str)
89-
{
90-
size_t index;
91-
for (index = str.size(); index > 0 && isspace(str[index - 1]); --index);
92-
str.erase(index);
93-
}
94-
void trim_whitespace(utility::string_t &str)
95-
{
96-
ltrim_whitespace(str);
97-
rtrim_whitespace(str);
98-
}
99-
10084
size_t chunked_encoding::add_chunked_delimiters(_Out_writes_(buffer_size) uint8_t *data, _In_ size_t buffer_size, size_t bytes_read)
10185
{
10286
size_t offset = 0;

Release/src/http/common/http_msg.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1212
****/
1313
#include "stdafx.h"
14+
#include "../common/internal_http_helpers.h"
1415

1516
using namespace web;
1617
using namespace utility;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/***
2+
* Copyright (C) Microsoft. All rights reserved.
3+
* Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
****/
5+
6+
#pragma once
7+
8+
#include "cpprest/details/basic_types.h"
9+
#include <string>
10+
11+
namespace web { namespace http { namespace details {
12+
13+
/// <summary>
14+
/// Helper function to get the default HTTP reason phrase for a status code.
15+
/// </summary>
16+
utility::string_t get_default_reason_phrase(status_code code);
17+
18+
// simple helper functions to trim whitespace.
19+
template<class Char>
20+
void trim_whitespace(std::basic_string<Char> &str)
21+
{
22+
size_t index;
23+
// trim left whitespace
24+
for (index = 0; index < str.size() && isspace(str[index]); ++index);
25+
str.erase(0, index);
26+
// trim right whitespace
27+
for (index = str.size(); index > 0 && isspace(str[index - 1]); --index);
28+
str.erase(index);
29+
}
30+
31+
bool validate_method(const utility::string_t& method);
32+
33+
}}}

0 commit comments

Comments
 (0)