class http_core_ : public _TelnetT
{
public:
- class url
- {
- private:
- int port_no;
- ::std::string host_s;
- ::std::string path_s;
- public:
- url(const char* url)
- {
- port_no = 80;
- //if ( strncmp(url, "http://") == 0 )
- const char* p_host = strstr(url,"://");
- if ( p_host == NULL )
- p_host = url;
- else
- p_host += 3;
-
- //const char* p_port_specify = strchr(
- const char* phost_slash = strchr(p_host,'/');
- if ( phost_slash == NULL )
- {
- host_s = p_host;
- path_s = "/";
- }
- else
- {
- host_s = ::std::string(p_host, phost_slash-p_host);
- //path = phost_slash+1;
- path_s = phost_slash;
- }
-
- const char* host_cstr = host_s.c_str();
- size_t n_port_colon = host_s.find(':');
- if ( n_port_colon != ::std::string::npos )
- {
- const char* p_port_colon = host_cstr + n_port_colon;
- port_no = atoi(p_port_colon+1);
- host_s.erase(p_port_colon - host_cstr);
- }
- }
-
- int get_portno(){ return port_no; }
- const char* get_host(){ return host_s.c_str(); }
- const char* get_path(){ return path_s.c_str(); }
- };
//////////////////////////////////////////////////////////////////////////////////////////////////////
typedef class request_header : public ::std::map< ::std::string, ::std::string >
{
public:
- void set_authorization(const char* auth_str) { operator []("Authorization") = auth_str; }
-
- void set_authorization_by_basic(const char* user, const char* pass)
- {
- ::std::string plain_user_pass = user;
- plain_user_pass += ':';
- plain_user_pass += pass;
- base64_enc be(plain_user_pass.c_str());
- //printf("%s\n", be.c_str());
-
- set_authorization( (::std::string("Basic ") + be.c_str()).c_str() );
- }
}
_request_header_t, _request_header;
return rstie(*this,stream::cout); }
protected:
- url m_url;
+ int m_port;
+ ::std::string m_host;
public:
http_core_() : m_url(""){ _init(); }
http_core_(const http_core_& from) :