From: Alex O. <al...@gm...> - 2007-12-13 10:13:59
|
Hello all On Dec 11, 2007 9:22 AM, Dean Michael Berris <mik...@gm...> wrote: > Hi Alex, > > On Dec 11, 2007 4:14 PM, Alex Ott <al...@gm...> wrote: > > > > i had looked into protocol/http/impl/request.hpp and had seen, that it > > include URI parser. i think, that it better to implement URI parser in > > their own namespace, as it could be used not only in http parsing, but > > also in other places. > > Yup, I agree. I intend to refactor those out later -- but that would > mean there would be tons of tests just to make sure that the parser is > correct. That sounds like a lot of work, but if you'd like to try that > out, please be my guest. :) Here is small patch, that could be useful - it should capture userinfo, that sometimes used in URI's. I'm thinking about rewriting URI part to complete matching to rfc 3986 Index: request.hpp =================================================================== --- request.hpp (revision 28) +++ request.hpp (working copy) @@ -30,6 +30,7 @@ class basic_request { struct tags { struct protocol { }; + struct userinfo { }; struct host { }; struct port { }; struct path { }; @@ -39,6 +40,7 @@ typedef fusion::map< fusion::pair<typename tags::protocol,typename tag::str_type>, + fusion::pair<typename tags::userinfo,typename tag::str_type>, fusion::pair<typename tags::host,typename tag::str_type>, fusion::pair<typename tags::port,unsigned int>, fusion::pair<typename tags::path,typename tag::str_type>, @@ -63,6 +65,14 @@ = construct_<typename tag::str_type>(arg1, arg2) ] >> str_p("://") + >> !( + >> (*(alnum_p | '.' | '-' | '_'| '~'|'!' | '$' | '&' | '\'' | '('| ')' + | '*' | '+' | ',' | ';' | '='))[ + var(fusion::at_key<typename tags::userinfo>(uri_parts)) + = construct_<typename tag::str_type>(arg1, arg2) + ] + >> ch_p('@') + ) >> (+(alnum_p | '.' | '-' | '_'))[ var(fusion::at_key<typename tags::host>(uri_parts)) = construct_<typename tag::str_type>(arg1, arg2) -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/ http://alexott-ru.blogspot.com/ http://content-filtering.blogspot.com/ http://xtalk.msk.su/~ott/ |