author | Michael Krelin <hacker@klever.net> | 2008-03-02 20:57:57 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-03-02 20:57:57 (UTC) |
commit | f6482fb9003e4953f838ba4ef2c110190355622f (patch) (side-by-side diff) | |
tree | 978ff6a8647c008cb3726c604b0749edb622171c | |
parent | da3f84153be2a93da7ffc49af33b29b9725fac38 (diff) | |
download | libopkele-f6482fb9003e4953f838ba4ef2c110190355622f.zip libopkele-f6482fb9003e4953f838ba4ef2c110190355622f.tar.gz libopkele-f6482fb9003e4953f838ba4ef2c110190355622f.tar.bz2 |
reinstated prefix handling in query building
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/types.h | 4 | ||||
-rw-r--r-- | lib/openid_message.cc | 20 |
2 files changed, 13 insertions, 11 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h index 1fab869..af7fb1a 100644 --- a/include/opkele/types.h +++ b/include/opkele/types.h @@ -136,14 +136,14 @@ namespace opkele { virtual bool has_ns(const string& uri) const; virtual string get_ns(const string& uri) const; virtual fields_iterator fields_begin() const = 0; virtual fields_iterator fields_end() const = 0; - virtual string append_query(const string& url) const; - virtual string query_string() const; + virtual string append_query(const string& url,const char *pfx="openid.") const; + virtual string query_string(const char *pfx="openid.") const; virtual void reset_fields(); virtual void set_field(const string& n,const string& v); virtual void reset_field(const string& n); diff --git a/lib/openid_message.cc b/lib/openid_message.cc index 75e59b3..4b9179b 100644 --- a/lib/openid_message.cc +++ b/lib/openid_message.cc @@ -64,19 +64,20 @@ namespace opkele { struct __om_query_builder : public unary_function<const string&,void> { public: const basic_openid_message& om; bool first; string& rv; + const char *pfx; - __om_query_builder(string& r,const basic_openid_message& m) - : om(m), first(true), rv(r) { + __om_query_builder(const char *p,string& r,const basic_openid_message& m) + : om(m), first(true), rv(r), pfx(p) { for_each(om.fields_begin(),om.fields_end(),*this); } - __om_query_builder(string& r,const basic_openid_message& m,const string& u) - : om(m), first(true), rv(r) { + __om_query_builder(const char *p,string& r,const basic_openid_message& m,const string& u) + : om(m), first(true), rv(r), pfx(p) { rv = u; if(rv.find('?')==string::npos) rv += '?'; else first = false; for_each(om.fields_begin(),om.fields_end(),*this); @@ -84,25 +85,26 @@ namespace opkele { result_type operator()(argument_type f) { if(first) first = false; else rv += '&'; - rv += "openid."; rv+= f; + if(pfx) rv += pfx; + rv+= f; rv += '='; rv += util::url_encode(om.get_field(f)); } }; - string basic_openid_message::append_query(const string& url) const { + string basic_openid_message::append_query(const string& url,const char *pfx) const { string rv; - return __om_query_builder(rv,*this,url).rv; + return __om_query_builder(pfx,rv,*this,url).rv; } - string basic_openid_message::query_string() const { + string basic_openid_message::query_string(const char *pfx) const { string rv; - return __om_query_builder(rv,*this).rv; + return __om_query_builder(pfx,rv,*this).rv; } void basic_openid_message::reset_fields() { throw not_implemented(OPKELE_CP_ "reset_fields() not implemented"); } void basic_openid_message::set_field(const string&,const string&) { |