Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use proper asio buffer ctor, fixes #7

  • Loading branch information...
commit e6a0aa69f19a0c064c3a87c3cb07258afd61c3c1 1 parent 7f087e5
@erikfrey erikfrey authored
Showing with 4 additions and 6 deletions.
  1. +4 −6 include/darner/net/handler.h
View
10 include/darner/net/handler.h
@@ -1,8 +1,6 @@
#ifndef __DARNER_HANDLER_HPP__
#define __DARNER_HANDLER_HPP__
-#include <sstream>
-
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/bind.hpp>
@@ -79,15 +77,15 @@ class handler : public boost::enable_shared_from_this<handler>
void end(const char* msg = "END\r\n")
{
+ buf_ = msg;
+
boost::asio::async_write(
- socket_, boost::asio::buffer(msg), boost::bind(&handler::read_request, shared_from_this(), _1, _2));
+ socket_, boost::asio::buffer(buf_), boost::bind(&handler::read_request, shared_from_this(), _1, _2));
}
void error(const char* msg, const char* error_type = "ERROR")
{
- std::ostringstream oss;
- oss << error_type << ' ' << msg << "\r\n";
- buf_ = oss.str();
+ buf_ = error_type + std::string(" ") + msg + std::string("\r\n");
boost::asio::async_write(
socket_, boost::asio::buffer(buf_), boost::bind(&handler::hang_up, shared_from_this(), _1, _2));
Please sign in to comment.
Something went wrong with that request. Please try again.