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( int16_t v );
fc::string to_string( uint16_t v );
fc::string to_string( size_t v );
fc::string to_string( long int v );
// fc::string to_string( size_t v );
// fc::string to_string( long int v );
template<typename T>
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 {
enum status_code {
OK = 200,
RecordCreated = 201,
NotFound = 404,
Found = 302,
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(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(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(unsigned char 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 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); }
explicit CBigNum(const std::vector<unsigned char>& vch)

View file

@ -32,10 +32,10 @@ namespace fc {
complete(false),
cur_task(0)
{
my_context.fc_stack.base = alloc.allocate( bc::minimum_stacksize() );
// slog( "new stack %1% bytes at %2%", bc::minimum_stacksize(), my_context.fc_stack.base );
my_context.fc_stack.base = alloc.allocate( bc::default_stacksize() );
// slog( "new stack %1% bytes at %2%", bc::default_stacksize(), my_context.fc_stack.base );
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 );
}
@ -52,7 +52,7 @@ namespace fc {
~context() {
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" );
}
}

View file

@ -1,7 +1,7 @@
#include <fc/exception.hpp>
#include <fc/error.hpp>
#include <boost/exception/all.hpp>
#include <boost/lexical_cast.hpp>
#include <fc/lexical_cast.hpp>
#include <boost/format.hpp>
namespace fc {
@ -72,16 +72,16 @@ namespace fc {
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( int64_t v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( double v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( float v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( int32_t v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( uint32_t v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( int16_t v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( uint16_t v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( size_t v ){ return boost::lexical_cast<std::string>(v).c_str(); }
fc::string to_string( long int 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 fc::lexical_cast<fc::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 fc::lexical_cast<fc::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 fc::lexical_cast<fc::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 fc::lexical_cast<fc::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 fc::lexical_cast<std::string>(v).c_str(); }
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 );

View file

@ -1,6 +1,7 @@
#include <fc/http/connection.hpp>
#include <fc/tcp_socket.hpp>
#include <fc/sstream.hpp>
#include <fc/iostream.hpp>
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,
const fc::string& url,
const fc::string& body ) {
fc::stringstream req;
req << method <<" "<<url<<" HTTP/1.1\r\n";
req << "Host: localhost\r\n";
if( body.size() ) req << "Content-Length: "<< body.size() << "\r\n";
req << "\r\n";
req << "\r\n";
fc::string head = req.str();
my->sock.write( head.c_str(), head.size() );
if( body.size() )
if( body.size() ) {
my->sock.write( body.c_str(), body.size() );
}
fc::cerr.flush();
return my->parse_reply();
}