added 201 reply status

This commit is contained in:
Daniel larimer 2012-10-24 01:58:17 -04:00
parent fb6e18ec7b
commit 70ee8caffe
6 changed files with 29 additions and 22 deletions

View file

@ -71,8 +71,8 @@ namespace fc {
fc::string to_string( uint32_t v ); fc::string to_string( uint32_t v );
fc::string to_string( int16_t v ); fc::string to_string( int16_t v );
fc::string to_string( uint16_t v ); fc::string to_string( uint16_t v );
fc::string to_string( size_t v ); // fc::string to_string( size_t v );
fc::string to_string( long int v ); // fc::string to_string( long int v );
template<typename T> template<typename T>
void throw_exception( const char* func, const char* file, int line, const char* msg, T&& a1 ) { void throw_exception( const char* func, const char* file, int line, const char* msg, T&& a1 ) {

View file

@ -17,6 +17,7 @@ namespace fc {
struct reply { struct reply {
enum status_code { enum status_code {
OK = 200, OK = 200,
RecordCreated = 201,
NotFound = 404, NotFound = 404,
Found = 302, Found = 302,
InternalServerError = 500 InternalServerError = 500

View file

@ -100,12 +100,12 @@ public:
CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } //CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int64_t n) { BN_init(this); setint64(n); } CBigNum(int64_t n) { BN_init(this); setint64(n); }
CBigNum(unsigned char n) { BN_init(this); setulong(n); } CBigNum(unsigned char n) { BN_init(this); setulong(n); }
CBigNum(unsigned short n) { BN_init(this); setulong(n); } CBigNum(unsigned short n) { BN_init(this); setulong(n); }
CBigNum(unsigned int n) { BN_init(this); setulong(n); } CBigNum(unsigned int n) { BN_init(this); setulong(n); }
CBigNum(unsigned long n) { BN_init(this); setulong(n); } //CBigNum(unsigned long n) { BN_init(this); setulong(n); }
CBigNum(uint64_t n) { BN_init(this); setuint64(n); } CBigNum(uint64_t n) { BN_init(this); setuint64(n); }
explicit CBigNum(const std::vector<unsigned char>& vch) explicit CBigNum(const std::vector<unsigned char>& vch)

View file

@ -32,10 +32,10 @@ namespace fc {
complete(false), complete(false),
cur_task(0) cur_task(0)
{ {
my_context.fc_stack.base = alloc.allocate( bc::minimum_stacksize() ); my_context.fc_stack.base = alloc.allocate( bc::default_stacksize() );
// slog( "new stack %1% bytes at %2%", bc::minimum_stacksize(), my_context.fc_stack.base ); // slog( "new stack %1% bytes at %2%", bc::default_stacksize(), my_context.fc_stack.base );
my_context.fc_stack.limit = my_context.fc_stack.limit =
static_cast<char*>( my_context.fc_stack.base) - bc::minimum_stacksize(); static_cast<char*>( my_context.fc_stack.base) - bc::default_stacksize();
make_fcontext( &my_context, sf ); make_fcontext( &my_context, sf );
} }
@ -52,7 +52,7 @@ namespace fc {
~context() { ~context() {
if(stack_alloc) { if(stack_alloc) {
stack_alloc->deallocate( my_context.fc_stack.base, bc::minimum_stacksize() ); stack_alloc->deallocate( my_context.fc_stack.base, bc::default_stacksize() );
// slog("deallocate stack" ); // slog("deallocate stack" );
} }
} }

View file

@ -1,7 +1,7 @@
#include <fc/exception.hpp> #include <fc/exception.hpp>
#include <fc/error.hpp> #include <fc/error.hpp>
#include <boost/exception/all.hpp> #include <boost/exception/all.hpp>
#include <boost/lexical_cast.hpp> #include <fc/lexical_cast.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
namespace fc { namespace fc {
@ -72,16 +72,16 @@ namespace fc {
fc::string to_string( char v ) { return fc::string(&v,1); } fc::string to_string( char v ) { return fc::string(&v,1); }
fc::string to_string( uint64_t v ) { return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( uint64_t v ) { return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( int64_t v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( int64_t v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( double v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( double v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( float v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( float v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( int32_t v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( int32_t v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( uint32_t v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( uint32_t v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( int16_t v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( int16_t v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( uint16_t v ){ return boost::lexical_cast<std::string>(v).c_str(); } fc::string to_string( uint16_t v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( size_t v ){ return boost::lexical_cast<std::string>(v).c_str(); } // fc::string to_string( size_t v ){ return fc::lexical_cast<fc::string>(v).c_str(); }
fc::string to_string( long int v ){ return boost::lexical_cast<std::string>(v).c_str(); } //fc::string to_string( long int v ){ return fc::lexical_cast<std::string>(v).c_str(); }
void throw_exception( const char* func, const char* file, int line, const char* msg ) { void throw_exception( const char* func, const char* file, int line, const char* msg ) {
::boost::exception_detail::throw_exception_(fc::generic_exception(msg),func, file, line ); ::boost::exception_detail::throw_exception_(fc::generic_exception(msg),func, file, line );

View file

@ -1,6 +1,7 @@
#include <fc/http/connection.hpp> #include <fc/http/connection.hpp>
#include <fc/tcp_socket.hpp> #include <fc/tcp_socket.hpp>
#include <fc/sstream.hpp> #include <fc/sstream.hpp>
#include <fc/iostream.hpp>
FC_START_SHARED_IMPL(fc::http::connection) FC_START_SHARED_IMPL(fc::http::connection)
@ -68,16 +69,21 @@ void connection::connect_to( const fc::ip::endpoint& ep ) {
http::reply connection::request( const fc::string& method, http::reply connection::request( const fc::string& method,
const fc::string& url, const fc::string& url,
const fc::string& body ) { const fc::string& body ) {
fc::stringstream req; fc::stringstream req;
req << method <<" "<<url<<" HTTP/1.1\r\n"; req << method <<" "<<url<<" HTTP/1.1\r\n";
req << "Host: localhost\r\n";
if( body.size() ) req << "Content-Length: "<< body.size() << "\r\n"; if( body.size() ) req << "Content-Length: "<< body.size() << "\r\n";
req << "\r\n"; req << "\r\n";
fc::string head = req.str(); fc::string head = req.str();
my->sock.write( head.c_str(), head.size() ); my->sock.write( head.c_str(), head.size() );
if( body.size() ) if( body.size() ) {
my->sock.write( body.c_str(), body.size() ); my->sock.write( body.c_str(), body.size() );
}
fc::cerr.flush();
return my->parse_reply(); return my->parse_reply();
} }