示例#1
0
gzstream::gzstream( std::iostream & strm,
                    unsigned int buffer_size )
    : std::iostream( static_cast< std::streambuf * >( 0 ) )
    , M_gzstreambuf( *(strm.rdbuf()), buffer_size )
{
    this->init( &M_gzstreambuf );
}
示例#2
0
    std::shared_ptr<Response> request(const std::string& request_type, const std::string& path, std::iostream& content,
      const std::map<std::string, std::string>& header = std::map<std::string, std::string>()) {
      std::string corrected_path = path;
      if (corrected_path == "")
        corrected_path = "/";

      content.seekp(0, std::ios::end);
      auto content_length = content.tellp();
      content.seekp(0, std::ios::beg);

      boost::asio::streambuf write_buffer;
      std::ostream write_stream(&write_buffer);
      write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n";
      write_stream << "Host: " << host << "\r\n";
      for (auto& h : header) {
        write_stream << h.first << ": " << h.second << "\r\n";
      }
      if (content_length>0)
        write_stream << "Content-Length: " << content_length << "\r\n";
      write_stream << "\r\n";
      if (content_length>0)
        write_stream << content.rdbuf();

      try {
        connect();

        boost::asio::write(*socket, write_buffer);
      }
      catch (const std::exception& e) {
        socket_error = true;
        throw std::invalid_argument(e.what());
      }

      return request_read();
    }
示例#3
0
/*!

*/
gzfilterstream::gzfilterstream( std::iostream & strm,
                                int level,
                                std::size_t buf_size )
    : std::iostream( static_cast< std::streambuf* >( 0 ) )
    , M_filter_buf( *(strm.rdbuf()), level, buf_size )

{
    // std::basic_ios::init( basic_streambuf<charT,traits>* sb );
    this->init( &M_filter_buf );
}