From: Gonzalo A. <ga...@us...> - 2006-09-12 00:29:04
|
Update of /cvsroot/mod-c/ehtml/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4922/src Modified Files: Request.cpp Log Message: * Added Request::~Request destructor. * Added Request::GetCookie method. * Made Request::HeaderEntry smarter (to avoid possible segfault). Index: Request.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/Request.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Request.cpp 11 Sep 2006 15:46:41 -0000 1.6 --- Request.cpp 12 Sep 2006 00:29:01 -0000 1.7 *************** *** 34,37 **** --- 34,45 ---- } + Request::~Request() { + while (!HeaderCookies.empty()) { + HeaderEntry* e = *HeaderCookies.begin(); + delete e; + HeaderCookies.pop_front(); + } + } + int Request::Prepare() { *************** *** 50,53 **** --- 58,62 ---- if ( r->args ) return ParseURLEncodedArgs( r->args, Arguments ); + PARSE_HEADER; break; *************** *** 120,126 **** --- 129,151 ---- } + const string* Request::GetCookie(const string& name) const { + printf("Looking for %s\n", name.c_str()); + string s = name + "="; + for (HeaderEntryList::const_iterator i = HeaderCookies.begin(); + i != HeaderCookies.end(); ++i) { + printf("cmp %s =? %s\n", name.c_str(), (*i)->Value); + if (!strncmp((*i)->Value, s.c_str(), s.length())) { + printf("got it! (%s)\n", (*i)->Value + name.length()+1); + cookies_returned.push_front(string((*i)->Value + name.length()+1)); + return &*cookies_returned.begin(); + } + } + return NULL; + } + void Request::ParseHeader() { const apr_array_header_t* arr = apr_table_elts( RequestContext->r->headers_in ); + printf("%s:%d\n", __PRETTY_FUNCTION__, __LINE__); if ( arr->nelts > 0 ) { *************** *** 136,139 **** --- 161,165 ---- if ( _key ) { + printf("Parsing %s\n", _key); switch ( _key[0] ) { *************** *** 154,158 **** if ( strncmp( "kie", _tmp + 1, 3 ) == 0 ) // We have a cookie ! HeaderCookies.push_back( ( HeaderEntry* ) tmp ); } // Is it Content-Length --- 180,185 ---- if ( strncmp( "kie", _tmp + 1, 3 ) == 0 ) // We have a cookie ! printf("Got cookie %s => %s\n", tmp->key, tmp->val); ! HeaderCookies.push_back( new HeaderEntry(tmp->key, tmp->val)); } // Is it Content-Length |