-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 | |||
@@ -140,6 +140,6 @@ namespace opkele { | |||
140 | virtual fields_iterator fields_end() const = 0; | 140 | virtual fields_iterator fields_end() const = 0; |
141 | 141 | ||
142 | virtual string append_query(const string& url) const; | 142 | virtual string append_query(const string& url,const char *pfx="openid.") const; |
143 | virtual string query_string() const; | 143 | virtual string query_string(const char *pfx="openid.") const; |
144 | 144 | ||
145 | 145 | ||
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 | |||
@@ -68,11 +68,12 @@ namespace opkele { | |||
68 | bool first; | 68 | bool first; |
69 | string& rv; | 69 | string& rv; |
70 | const char *pfx; | ||
70 | 71 | ||
71 | __om_query_builder(string& r,const basic_openid_message& m) | 72 | __om_query_builder(const char *p,string& r,const basic_openid_message& m) |
72 | : om(m), first(true), rv(r) { | 73 | : om(m), first(true), rv(r), pfx(p) { |
73 | for_each(om.fields_begin(),om.fields_end(),*this); | 74 | for_each(om.fields_begin(),om.fields_end(),*this); |
74 | } | 75 | } |
75 | __om_query_builder(string& r,const basic_openid_message& m,const string& u) | 76 | __om_query_builder(const char *p,string& r,const basic_openid_message& m,const string& u) |
76 | : om(m), first(true), rv(r) { | 77 | : om(m), first(true), rv(r), pfx(p) { |
77 | rv = u; | 78 | rv = u; |
78 | if(rv.find('?')==string::npos) | 79 | if(rv.find('?')==string::npos) |
@@ -88,5 +89,6 @@ namespace opkele { | |||
88 | else | 89 | else |
89 | rv += '&'; | 90 | rv += '&'; |
90 | rv += "openid."; rv+= f; | 91 | if(pfx) rv += pfx; |
92 | rv+= f; | ||
91 | rv += '='; | 93 | rv += '='; |
92 | rv += util::url_encode(om.get_field(f)); | 94 | rv += util::url_encode(om.get_field(f)); |
@@ -94,11 +96,11 @@ namespace opkele { | |||
94 | }; | 96 | }; |
95 | 97 | ||
96 | string basic_openid_message::append_query(const string& url) const { | 98 | string basic_openid_message::append_query(const string& url,const char *pfx) const { |
97 | string rv; | 99 | string rv; |
98 | return __om_query_builder(rv,*this,url).rv; | 100 | return __om_query_builder(pfx,rv,*this,url).rv; |
99 | } | 101 | } |
100 | string basic_openid_message::query_string() const { | 102 | string basic_openid_message::query_string(const char *pfx) const { |
101 | string rv; | 103 | string rv; |
102 | return __om_query_builder(rv,*this).rv; | 104 | return __om_query_builder(pfx,rv,*this).rv; |
103 | } | 105 | } |
104 | 106 | ||