MACE
1.0.0
|
00001 // 00002 // reply.hpp 00003 // ~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef MACE_RPC_HTTP_REPLY_HPP 00012 #define MACE_RPC_HTTP_REPLY_HPP 00013 00014 #include <string> 00015 #include <vector> 00016 #include <boost/asio.hpp> 00017 #include <mace/rpc/http/header.hpp> 00018 00019 namespace mace { namespace rpc { namespace http { 00020 00022 struct reply { 00024 enum status_type { 00025 ok = 200, 00026 created = 201, 00027 accepted = 202, 00028 no_content = 204, 00029 multiple_choices = 300, 00030 moved_permanently = 301, 00031 moved_temporarily = 302, 00032 not_modified = 304, 00033 bad_request = 400, 00034 unauthorized = 401, 00035 forbidden = 403, 00036 not_found = 404, 00037 internal_server_error = 500, 00038 not_implemented = 501, 00039 bad_gateway = 502, 00040 service_unavailable = 503 00041 } status; 00042 00043 reply():keep_alive(false){} 00044 00045 bool keep_alive; 00046 00048 std::vector<header> headers; 00049 00051 std::vector<char> content; 00052 00056 std::vector<boost::asio::const_buffer> to_buffers(); 00057 00059 static reply stock_reply(status_type status); 00060 00061 template<typename Stream> 00062 friend Stream& operator << (Stream& s, const reply& r ) { 00063 if( r.content.size() ) 00064 s.write( &r.content.front(), r.content.size() ); 00065 return s; 00066 } 00067 }; 00068 00069 } } } // mace::rpc::http 00070 00071 #endif // MACE_RPC_HTTP_REPLY_HPP