From 157ca678dee75e7881a0198425d0c8328f0bee04 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Thu, 3 Jan 2013 07:41:02 +0000 Subject: Improve handling of nested lists, trees, null and floating point values. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1428191 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/http/http.hpp | 5 ++--- sca-cpp/trunk/modules/http/httpd.hpp | 26 +++++++++++++------------- sca-cpp/trunk/modules/http/mod-openauth.cpp | 6 +++--- sca-cpp/trunk/modules/http/openauth.hpp | 6 +++--- 4 files changed, 21 insertions(+), 22 deletions(-) (limited to 'sca-cpp/trunk/modules/http') diff --git a/sca-cpp/trunk/modules/http/http.hpp b/sca-cpp/trunk/modules/http/http.hpp index 1153f61840..cd0eb6c04b 100644 --- a/sca-cpp/trunk/modules/http/http.hpp +++ b/sca-cpp/trunk/modules/http/http.hpp @@ -87,7 +87,6 @@ public: return; if (h.h == NULL) return; - debug(h.h, "http::~CURLSession::cleanup::h"); curl_easy_cleanup(h.h); } @@ -943,7 +942,7 @@ const failable recv(char* const c, const size_t l, const CURLSession& cs /** * Converts a list of key value pairs to a query string. */ -ostringstream& queryString(const list > args, ostringstream& os) { +ostringstream& queryString(const list& args, ostringstream& os) { if (isNil(args)) return os; const list arg = car(args); @@ -956,7 +955,7 @@ ostringstream& queryString(const list > args, ostringstream& os) { return queryString(cdr(args), os); } -const string queryString(const list > args) { +const string queryString(const list& args) { ostringstream os; return str(queryString(args, os)); } diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index e090c2fc35..255f0aa31b 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -330,13 +330,13 @@ const string unescape(const string& uri) { /** * Unescape a list of key of value pairs representing query args. */ -const list unescapeArg(const list a) { - return mklist(car(a), unescape(cadr(a))); +const value unescapeArg(const value& a) { + return mklist(car(a), unescape(cadr(a))); } -const list > unescapeArgs(const list > args) { +const list unescapeArgs(const list& args) { debug(args, "httpd::unescape::args"); - const list > uargs = map, list>(unescapeArg, args); + const list uargs = map(unescapeArg, args); debug(uargs, "httpd::unescape::result"); return uargs; } @@ -344,7 +344,7 @@ const list > unescapeArgs(const list > args) { /** * Returns a list of key value pairs from the args in a query string. */ -const list queryArg(const string& s) { +const value queryArg(const string& s) { debug(s, "httpd::queryArg::string"); const list t = tokenize("=", s); if (isNil(cdr(t))) @@ -359,27 +359,27 @@ const string fixupQueryArgs(const string& a) { return join("&", t); } -const list > queryArgs(const string& a) { - return map>(queryArg, tokenize("&", fixupQueryArgs(a))); +const list queryArgs(const string& a) { + return map(queryArg, tokenize("&", fixupQueryArgs(a))); } /** * Returns a list of key value pairs from the args in an HTTP request. */ -const list > queryArgs(const request_rec* const r) { +const list queryArgs(const request_rec* const r) { if (r->args == NULL) - return list >(); + return nilListValue; return queryArgs(r->args); } /** * Converts the args received in a POST to a list of key value pairs. */ -const list > postArgs(const list& a) { +const list postArgs(const list& a) { if (isNil(a)) - return list >(); + return nilListValue; const list l = car(a); - return cons(l, postArgs(cdr(a))); + return cons(l, postArgs(cdr(a))); } /** @@ -397,7 +397,7 @@ const int setupReadPolicy(request_rec* const r) { } /** - * Read the content of a POST or PUT. + * Read the content of an HTTP request. */ const list read(request_rec* const r) { char b[1024]; diff --git a/sca-cpp/trunk/modules/http/mod-openauth.cpp b/sca-cpp/trunk/modules/http/mod-openauth.cpp index 797e8c10b5..1b70f27744 100644 --- a/sca-cpp/trunk/modules/http/mod-openauth.cpp +++ b/sca-cpp/trunk/modules/http/mod-openauth.cpp @@ -178,7 +178,7 @@ const failable userInfoFromSession(const string& realm, request_rec* cons * Return the user info from a form auth session cookie. */ const failable userInfoFromCookie(const value& sid, const string& realm, request_rec* const r) { - const list> info = httpd::queryArgs(sid); + const list info = httpd::queryArgs(sid); debug(info, "modopenauth::userInfoFromCookie::info"); const list user = assoc(realm + "-user", info); if(isNil(user)) @@ -212,7 +212,7 @@ const failable userInfoFromHeader(const char* header, const string& realm /** * Handle an authenticated request. */ -const failable authenticated(const list >& info, request_rec* const r) { +const failable authenticated(const list& info, request_rec* const r) { debug(info, "modopenauth::authenticated::info"); // Store user info in the request @@ -248,7 +248,7 @@ static int checkAuthn(request_rec* const r) { debug(atype, "modopenauth::checkAuthn::auth_type"); // Get the request args - const list > args = httpd::queryArgs(r); + const list args = httpd::queryArgs(r); // Get session id from the request const maybe sid = sessionID(r, "TuscanyOpenAuth"); diff --git a/sca-cpp/trunk/modules/http/openauth.hpp b/sca-cpp/trunk/modules/http/openauth.hpp index dcf405d487..1c49c4254c 100644 --- a/sca-cpp/trunk/modules/http/openauth.hpp +++ b/sca-cpp/trunk/modules/http/openauth.hpp @@ -92,9 +92,9 @@ const string cookie(const string& key, const string& sid, const string& domain) * Redirect to the configured login page. */ const failable login(const string& page, const value& ref, const value& attempt, request_rec* const r) { - const list > rarg = ref == string("/")? list >() : mklist >(mklist("openauth_referrer", httpd::escape(httpd::url(isNil(ref)? r->uri : ref, r)))); - const list > aarg = isNil(attempt)? list >() : mklist >(mklist("openauth_attempt", attempt)); - const list > largs = append >(rarg, aarg); + const list rarg = ref == string("/")? nilListValue : mklist(mklist("openauth_referrer", httpd::escape(httpd::url(isNil(ref)? r->uri : ref, r)))); + const list aarg = isNil(attempt)? nilListValue : mklist(mklist("openauth_attempt", attempt)); + const list largs = append(rarg, aarg); const string loc = isNil(largs)? httpd::url(page, r) : httpd::url(page, r) + string("?") + http::queryString(largs); debug(loc, "openauth::login::uri"); return httpd::externalRedirect(loc, r); -- cgit v1.2.3