OSDN Git Service

http_core.hpp: HTTPバージョン周りの修正
authorMyun2 <myun2@nwhite.info>
Tue, 14 Dec 2010 09:27:07 +0000 (18:27 +0900)
committerMyun2 <myun2@nwhite.info>
Tue, 14 Dec 2010 09:27:07 +0000 (18:27 +0900)
roast/include/roast/net/http_core.hpp
roast/include/roast/net/socket.hpp

index 67553db..8f7b68d 100644 (file)
 #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_DEFAULT_VERSION     ROAST_HTTP_VER_1_0
 #define _ROAST_HTTP_CRLF       "\r\n"
 
 namespace roast
 {
-       class http_request_header : public ::std::map<::std::string, ::std::string>
-       {
-       public:
-       };
-       
-       ///////////////////
-       
+       typedef ::std::map<::std::string, ::std::string> http_request_header;
        typedef ::std::map<::std::string, ::std::string> http_response_header;
        
        ///////////////////
@@ -37,6 +30,15 @@ namespace roast
                typedef ::roast::http_request_header request_header;
                typedef ::roast::http_response_header response_header;
 
+               enum httpver
+               {
+                       v09=9,
+                       v10,
+                       v11
+               };
+#define _ROAST_HTTP_DEFAULT_HTTP_VERSION               v11
+#define _ROAST_HTTP_DEFAULT_HTTP_VERSION_STR   ROAST_HTTP_VER_1_1
+
                class response
                {
                private:
@@ -103,7 +105,8 @@ namespace roast
 
                const ::std::string m_host;
                const int m_port;
-               const ::std::string m_httpver;
+               const char* m_httpver_str;
+               httpver m_httpver;
 
                stream::tie_ostream _req_ost(){
                        return rstie(*this,stream::cout); }
@@ -120,10 +123,25 @@ namespace roast
                }
 
        public:
-               http_core_(const char* host, int port_no=80, const char* http_version=ROAST_HTTP_VER_1_0) :
+               http_core_(const char* host, int port_no=80, httpver http_version=_ROAST_HTTP_DEFAULT_HTTP_VERSION) :
                        m_host(host), m_port(port_no), m_httpver(http_version)
                {
-                       connect(m_host.c_str(), port_no);
+                       m_httpver_str = _ROAST_HTTP_DEFAULT_HTTP_VERSION_STR;
+
+                       switch(m_httpver)
+                       {
+                       case v09:
+                               m_httpver_str = ROAST_HTTP_VER_0_9;
+                               break;
+                       case v10:
+                               m_httpver_str = ROAST_HTTP_VER_1_0;
+                               break;
+                       case v11:
+                               m_httpver_str = ROAST_HTTP_VER_1_1;
+                               break;
+                       }
+                       
+                       //connect(m_host.c_str(), port_no);
                }
 
                /////////////////////////////////////////////////
index 9e07a3b..23591da 100644 (file)
@@ -57,8 +57,10 @@ namespace roast
                                hints.ai_socktype = socktype;
                                hints.ai_family = family;
 
+#pragma warning(disable: 4996)
                                char port_str[12];
                                sprintf(port_str, "%d", port);
+#pragma warning(default: 4996)
 
                                //if ( !m_impl.getaddrinfo(host, port_str, &hints, &addr) )
                                if ( !m_pimpl->getaddrinfo(host, port_str, &hints, &addr) )