bug fixes and improvements
This commit is contained in:
parent
9a8767a645
commit
efca814f0b
3 changed files with 44 additions and 3 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef _FC_FILESYSTEM_HPP_
|
#pragma once
|
||||||
#define _FC_FILESYSTEM_HPP_
|
|
||||||
#include <fc/string.hpp>
|
#include <fc/string.hpp>
|
||||||
#include <fc/fwd.hpp>
|
#include <fc/fwd.hpp>
|
||||||
|
|
||||||
|
|
@ -72,4 +71,3 @@ namespace fc {
|
||||||
path temp_directory_path();
|
path temp_directory_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _FC_FILESYSTEM_HPP_
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ namespace fc {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct request {
|
struct request {
|
||||||
|
fc::string get_header( const fc::string& key )const;
|
||||||
fc::string method;
|
fc::string method;
|
||||||
fc::string domain;
|
fc::string domain;
|
||||||
fc::string path;
|
fc::string path;
|
||||||
|
|
@ -39,6 +40,8 @@ namespace fc {
|
||||||
fc::vector<char> body;
|
fc::vector<char> body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fc::vector<header> parse_urlencoded_params( const fc::string& f );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connections have reference semantics, all copies refer to the same
|
* Connections have reference semantics, all copies refer to the same
|
||||||
* underlying socket.
|
* underlying socket.
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <fc/iostream.hpp>
|
#include <fc/iostream.hpp>
|
||||||
#include <fc/exception.hpp>
|
#include <fc/exception.hpp>
|
||||||
#include <fc/ip.hpp>
|
#include <fc/ip.hpp>
|
||||||
|
#include <fc/error_report.hpp>
|
||||||
|
#include <fc/hex.hpp>
|
||||||
|
|
||||||
|
|
||||||
FC_START_SHARED_IMPL(fc::http::connection)
|
FC_START_SHARED_IMPL(fc::http::connection)
|
||||||
|
|
@ -154,4 +156,42 @@ http::request connection::read_request()const {
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fc::string request::get_header( const fc::string& key )const {
|
||||||
|
for( auto itr = headers.begin(); itr != headers.end(); ++itr ) {
|
||||||
|
if( itr->key == key ) { return itr->val; }
|
||||||
|
}
|
||||||
|
return fc::string();
|
||||||
|
}
|
||||||
|
fc::vector<header> parse_urlencoded_params( const fc::string& f ) {
|
||||||
|
int num_args = 0;
|
||||||
|
for( size_t i = 0; i < f.size(); ++i ) {
|
||||||
|
if( f[i] == '=' ) ++num_args;
|
||||||
|
}
|
||||||
|
fc::vector<header> h(num_args);
|
||||||
|
int arg = 0;
|
||||||
|
for( size_t i = 0; i < f.size(); ++i ) {
|
||||||
|
while( f[i] != '=' && i < f.size() ) {
|
||||||
|
if( f[i] == '%' ) {
|
||||||
|
h[arg].key += char((fc::from_hex(f[i+1]) << 4) | fc::from_hex(f[i+2]));
|
||||||
|
i += 3;
|
||||||
|
} else {
|
||||||
|
h[arg].key += f[i];
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
while( i < f.size() && f[i] != '&' ) {
|
||||||
|
if( f[i] == '%' ) {
|
||||||
|
h[arg].val += char((fc::from_hex(f[i+1]) << 4) | fc::from_hex(f[i+2]));
|
||||||
|
i += 3;
|
||||||
|
} else {
|
||||||
|
h[arg].val += f[i] == '+' ? ' ' : f[i];
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++arg;
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
} } // fc::http
|
} } // fc::http
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue