#ifndef __SFJP_ROAST__net__http_HPP__
#define __SFJP_ROAST__net__http_HPP__
-#include "roast/net/telnet.hpp"
-#include "roast/net/base64.hpp"
-#include "roast/stream/stream.hpp" // for Debug Print
-#include <string>
-#include <map>
-#include <vector>
-
-#define ROAST_HTTP_VER_0_9 "0.9"
-#define ROAST_HTTP_VER_1_0 "1.0"
-#define ROAST_HTTP_VER_1_1 "1.1"
-
-#define _ROAST_HTTP_REQUEST_DEFAULT_VERSION ROAST_HTTP_VER_1_0
+#include "roast/net/http_core.hpp"
namespace roast
{
template <typename _TelnetT = ::roast::telnet >
- class http_ : public _TelnetT
+ class http_ : public http_core_<_TelnetT>
{
public:
class url
//////////////////////////////////////////////////////////////////////////////////////////////////////
- typedef ::std::map< ::std::string, ::std::string > _response_header_t, _response_header, response_header;
-
- class response
- {
- private:
- int m_now_flg;
- public:
- const char* version;
- int status_code;
- _response_header headers;
- ::std::string body;
-
- public:
- response(){
- m_now_flg = 0;
- }
-
- bool operator << (_TelnetT &tn)
- {
- ::std::string s;
- tn _ROAST_STREAM_OROP s;
-
- // 0: Status Line
- if ( m_now_flg == 0 )
- {
- const char* p_s = s.c_str();
- version = p_s + 5;
- status_code = atoi(p_s + 8);
-
- m_now_flg = 1;
- }
-
- // 1: Header Lines
- else if ( m_now_flg == 1 )
- {
- /*if ( s.size() <= 2 )
- m_now_flg = 2;
- else
- {*/
- size_t n_colon = s.find(':');
- if ( n_colon == ::std::string::npos )
- m_now_flg = 2;
- else
- {
- ::std::string s_header_name = s.substr(0, n_colon);
- headers[ s_header_name ] = s.c_str() + n_colon + 1;
- }
- //}
- }
- // 2: Body
- else
- {
- body += s;
- }
-
- // Debug Print
- //fputs(s.c_str(), stdout);
-
- //m_n_line++;
- return !tn.is_eos();
- }
- };
-
private:
typedef _TelnetT _Base;