From 24a6f9e3525b76ed1aa787f66b003b01b767af39 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 16 Dec 2007 22:52:51 +0000 Subject: 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 --- (limited to 'lib/params.cc') 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 { return rv; } + string params_t::query_string(const char *prefix) const { + string rv; + for(const_iterator i=begin();i!=end();++i) { + if(!rv.empty()) + rv += '&'; + rv += prefix; + rv += i->first; + rv += '='; + rv += util::url_encode(i->second); + } + return rv; + } + ostream& operator << (ostream& o,const params_t& p) { for(params_t::const_iterator i=p.begin();i!=p.end();++i) o << i->first << ':' << i->second << '\n'; -- cgit v0.9.0.2