author | Michael Krelin <hacker@klever.net> | 2007-12-16 22:52:51 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-12-17 12:09:16 (UTC) |
commit | 24a6f9e3525b76ed1aa787f66b003b01b767af39 (patch) (unidiff) | |
tree | 87741582a2a673205b11ac0386725c0b9d8377f9 /lib/params.cc | |
parent | d4e05a6fe00ebd64546637e5873759d4e8d1b010 (diff) | |
download | libopkele-24a6f9e3525b76ed1aa787f66b003b01b767af39.zip libopkele-24a6f9e3525b76ed1aa787f66b003b01b767af39.tar.gz libopkele-24a6f9e3525b76ed1aa787f66b003b01b767af39.tar.bz2 |
made secret_t non-constant size and added params_t::query_string function
1. removed checking that secret_t is exactly 20 bytes, because its size is not
so constant anymore.
2. added a query_string function that produces a query string suitable for use
in GET and POST requests. I'm making use of it when performing direct
request when establishing associations.
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/params.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/params.cc b/lib/params.cc index ea86d3a..7a572c1 100644 --- a/lib/params.cc +++ b/lib/params.cc | |||
@@ -99,6 +99,19 @@ namespace opkele { | |||
99 | return rv; | 99 | return rv; |
100 | } | 100 | } |
101 | 101 | ||
102 | string params_t::query_string(const char *prefix) const { | ||
103 | string rv; | ||
104 | for(const_iterator i=begin();i!=end();++i) { | ||
105 | if(!rv.empty()) | ||
106 | rv += '&'; | ||
107 | rv += prefix; | ||
108 | rv += i->first; | ||
109 | rv += '='; | ||
110 | rv += util::url_encode(i->second); | ||
111 | } | ||
112 | return rv; | ||
113 | } | ||
114 | |||
102 | ostream& operator << (ostream& o,const params_t& p) { | 115 | ostream& operator << (ostream& o,const params_t& p) { |
103 | for(params_t::const_iterator i=p.begin();i!=p.end();++i) | 116 | for(params_t::const_iterator i=p.begin();i!=p.end();++i) |
104 | o << i->first << ':' << i->second << '\n'; | 117 | o << i->first << ':' << i->second << '\n'; |