[complement-svn] SF.net SVN: complement: [1781] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-10-31 17:40:07
|
Revision: 1781 http://complement.svn.sourceforge.net/complement/?rev=1781&view=rev Author: complement Date: 2007-10-31 10:40:04 -0700 (Wed, 31 Oct 2007) Log Message: ----------- prepare for move http.* to net Modified Paths: -------------- trunk/complement/explore/app/intercessor/http.cc trunk/complement/explore/app/intercessor/http.h Added Paths: ----------- trunk/complement/explore/include/net/http.h Modified: trunk/complement/explore/app/intercessor/http.cc =================================================================== --- trunk/complement/explore/app/intercessor/http.cc 2007-10-31 17:38:28 UTC (rev 1780) +++ trunk/complement/explore/app/intercessor/http.cc 2007-10-31 17:40:04 UTC (rev 1781) @@ -1,6 +1,6 @@ // -*- C++ -*- Time-stamp: <07/03/07 15:17:27 ptr> -#include "http.h" +#include <net/http.h> #include <istream> #include <ostream> #include <iomanip> @@ -135,6 +135,36 @@ return s; } +boost::regex cookie_re( "(?:(\\w+)=([^;]*)(?:;\\s+)?)*" ); + +cookie::cookie( const header& h ) +{ + if ( h.key() == "Set-Cookie" ) { + boost::smatch ma; + if ( regex_search( h.value(), ma, cookie_re, boost::match_extra ) ) { +#ifdef BOOST_REGEX_MATCH_EXTRA + for ( int j = 0; j < ma.captures(1).size(); ++j ) { + if ( ma.captures(1)[j] == "path" ) { + _path = ma.captures(2)[j]; + } else if ( ma.captures(1)[j] == "expires" ) { + _expires = ma.captures(2)[j]; + } else if ( ma.captures(1)[j] == "Expires" ) { + _expires = ma.captures(2)[j]; + } else if ( ma.captures(1)[j] == "domain" ) { + _domain = ma.captures(2)[j]; + } else if ( ma.captures(1)[j] == "comment" ) { + } else if ( ma.captures(1)[j] == "max-age" ) { + } else if ( ma.captures(1)[j] == "version" ) { + } else { + _val.first = ma.captures(1)[j]; + _val.second = ma.captures(2)[j]; + } + } +#endif + } + } +} + std::ostream& operator <<( std::ostream& s, const base_response& r ) { s << (r._proto == command::HTTP10 ? http10 : http11) << ' ' << setfill( '0' ) << setw(3) << r._code << ' '; Modified: trunk/complement/explore/app/intercessor/http.h =================================================================== --- trunk/complement/explore/app/intercessor/http.h 2007-10-31 17:38:28 UTC (rev 1780) +++ trunk/complement/explore/app/intercessor/http.h 2007-10-31 17:40:04 UTC (rev 1781) @@ -178,6 +178,35 @@ std::ostream& operator <<( std::ostream& s, const header& h ); std::istream& operator >>( std::istream& s, header& h ); +class cookie +{ + public: + + cookie() + { } + + cookie( const header& ); + + const std::string& key() const + { return _val.first; } + + const std::string& value() const + { return _val.second; } + + void key( const std::string& k ) + { _val.first = k; } + + // template <> + void value( const std::string& v ) + { _val.second = v; } + + private: + std::pair<std::string,std::string> _val; + std::string _domain; + std::string _path; + std::string _expires; +}; + class base_response { public: @@ -397,6 +426,8 @@ if ( skws ) { s.setf( std::ios_base::skipws ); } + } else { // server not HTTP 1.1-compliant (RFC2616, 4.4) + copy( std::istreambuf_iterator<char>(s.rdbuf()), std::istreambuf_iterator<char>(), back_inserter(r._body) ); } } } Added: trunk/complement/explore/include/net/http.h =================================================================== --- trunk/complement/explore/include/net/http.h (rev 0) +++ trunk/complement/explore/include/net/http.h 2007-10-31 17:40:04 UTC (rev 1781) @@ -0,0 +1 @@ +link ../../app/intercessor/http.h \ No newline at end of file Property changes on: trunk/complement/explore/include/net/http.h ___________________________________________________________________ Name: svn:special + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |