Skip to content

Commit 524d5b4

Browse files
committed
Fixing more locations for locale issues on Linux.
1 parent 5e1ea52 commit 524d5b4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Release/src/http/client/http_client_asio.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ class asio_context : public request_context, public std::enable_shared_from_this
380380

381381
const auto &host = base_uri.host();
382382
std::ostream request_stream(&m_body_buf);
383+
request_stream.imbue(std::locale::classic());
383384

384385
request_stream << method << " " << encoded_resource << " " << "HTTP/1.1" << CRLF << "Host: " << host;
385386

@@ -768,6 +769,7 @@ class asio_context : public request_context, public std::enable_shared_from_this
768769
m_timer.reset();
769770

770771
std::istream response_stream(&m_body_buf);
772+
response_stream.imbue(std::locale::classic());
771773
std::string http_version;
772774
response_stream >> http_version;
773775
status_code status_code;
@@ -783,9 +785,6 @@ class asio_context : public request_context, public std::enable_shared_from_this
783785

784786
if (!response_stream || http_version.substr(0, 5) != "HTTP/")
785787
{
786-
printf("HTTP VERSION:%s\n", http_version.c_str());
787-
printf("Status_code:%hu\n", status_code);
788-
printf("Status message:%s\n", status_message.c_str());
789788
report_error("Invalid HTTP status line", ec, httpclient_errorcode_context::readheader);
790789
return;
791790
}
@@ -826,6 +825,7 @@ class asio_context : public request_context, public std::enable_shared_from_this
826825
{
827826
auto needChunked = false;
828827
std::istream response_stream(&m_body_buf);
828+
response_stream.imbue(std::locale::classic());
829829
std::string header;
830830
while (std::getline(response_stream, header) && header != "\r")
831831
{
@@ -913,6 +913,7 @@ class asio_context : public request_context, public std::enable_shared_from_this
913913
m_timer.reset();
914914

915915
std::istream response_stream(&m_body_buf);
916+
response_stream.imbue(std::locale::classic());
916917
std::string line;
917918
std::getline(response_stream, line);
918919

Release/src/http/listener/http_server_asio.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ void connection::handle_http_line(const boost::system::error_code& ec)
252252
{
253253
// read http status line
254254
std::istream request_stream(&m_request_buf);
255+
request_stream.imbue(std::locale::classic());
255256
std::skipws(request_stream);
256257

257258
std::string http_verb;
@@ -325,6 +326,7 @@ void connection::handle_http_line(const boost::system::error_code& ec)
325326
void connection::handle_headers()
326327
{
327328
std::istream request_stream(&m_request_buf);
329+
request_stream.imbue(std::locale::classic());
328330
std::string header;
329331
while (std::getline(request_stream, header) && header != "\r")
330332
{
@@ -405,6 +407,7 @@ void connection::handle_chunked_header(const boost::system::error_code& ec)
405407
else
406408
{
407409
std::istream is(&m_request_buf);
410+
is.imbue(std::locale::classic());
408411
int len;
409412
is >> std::hex >> len;
410413
m_request_buf.consume(CRLF.size());
@@ -589,6 +592,7 @@ void connection::async_process_response(http_response response)
589592
{
590593
m_response_buf.consume(m_response_buf.size()); // clear the buffer
591594
std::ostream os(&m_response_buf);
595+
os.imbue(std::locale::classic());
592596

593597
os << "HTTP/1.1 " << response.status_code() << " "
594598
<< response.reason_phrase()

0 commit comments

Comments
 (0)