src: Use util::utos instead of std::to_string

Some platform (e.g., freebsd) does not define _GLIBCXX_USE_C99
and it hides std::to_string functions.
This commit is contained in:
Tatsuhiro Tsujikawa 2013-09-08 14:29:18 +09:00
parent f233a1a45e
commit 1a05caf847
3 changed files with 7 additions and 7 deletions

View File

@ -871,7 +871,7 @@ void submit_request(HttpClient *client,
std::string content_length_str; std::string content_length_str;
if(req->data_prd) { if(req->data_prd) {
content_length_str = std::to_string(req->data_length); content_length_str = util::utos(req->data_length);
nv[pos++] = "content-length"; nv[pos++] = "content-length";
nv[pos++] = content_length_str.c_str(); nv[pos++] = content_length_str.c_str();
} }

View File

@ -680,7 +680,7 @@ void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr)
if(downstream->get_response_state() == Downstream::HEADER_COMPLETE) { if(downstream->get_response_state() == Downstream::HEADER_COMPLETE) {
upstream->rst_stream(downstream, NGHTTP2_INTERNAL_ERROR); upstream->rst_stream(downstream, NGHTTP2_INTERNAL_ERROR);
} else { } else {
int status; unsigned int status;
if(events & BEV_EVENT_TIMEOUT) { if(events & BEV_EVENT_TIMEOUT) {
status = 504; status = 504;
} else { } else {
@ -771,7 +771,8 @@ ssize_t spdy_data_read_callback(nghttp2_session *session,
} }
} // namespace } // namespace
int Http2Upstream::error_reply(Downstream *downstream, int status_code) int Http2Upstream::error_reply(Downstream *downstream,
unsigned int status_code)
{ {
int rv; int rv;
auto html = http::create_error_html(status_code); auto html = http::create_error_html(status_code);
@ -789,7 +790,7 @@ int Http2Upstream::error_reply(Downstream *downstream, int status_code)
data_prd.read_callback = spdy_data_read_callback; data_prd.read_callback = spdy_data_read_callback;
auto content_length = util::utos(html.size()); auto content_length = util::utos(html.size());
auto status_code_str = std::to_string(status_code); auto status_code_str = util::utos(status_code);
const char *nv[] = { const char *nv[] = {
":status", status_code_str.c_str(), ":status", status_code_str.c_str(),
"content-type", "text/html; charset=UTF-8", "content-type", "text/html; charset=UTF-8",
@ -861,8 +862,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream)
auto nv = util::make_unique<const char*[]>(nheader * 2 + 4 + 1); auto nv = util::make_unique<const char*[]>(nheader * 2 + 4 + 1);
size_t hdidx = 0; size_t hdidx = 0;
std::string via_value; std::string via_value;
auto response_status = auto response_status = util::utos(downstream->get_response_http_status());
std::to_string(downstream->get_response_http_status());
nv[hdidx++] = ":status"; nv[hdidx++] = ":status";
nv[hdidx++] = response_status.c_str(); nv[hdidx++] = response_status.c_str();

View File

@ -57,7 +57,7 @@ public:
int rst_stream(Downstream *downstream, nghttp2_error_code error_code); int rst_stream(Downstream *downstream, nghttp2_error_code error_code);
int window_update(Downstream *downstream); int window_update(Downstream *downstream);
int error_reply(Downstream *downstream, int status_code); int error_reply(Downstream *downstream, unsigned int status_code);
virtual void pause_read(IOCtrlReason reason); virtual void pause_read(IOCtrlReason reason);
virtual int resume_read(IOCtrlReason reason, Downstream *downstream); virtual int resume_read(IOCtrlReason reason, Downstream *downstream);