diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-24 02:54:39 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-24 02:54:39 +0000 |
commit | 74aef8947b7b72eca797a2f55d39997cc7af9c25 (patch) | |
tree | 60992d5a27fb7d10e2e6b280cad4dfde9256c043 /sca-cpp/trunk/modules/server/mod-eval.hpp | |
parent | e5f662ac57fa2c54882245e1c568e0982abab4fb (diff) |
Fix roundtripping of JSON arrays, booleans and numbers, ATOM / RSS feed detection, and support REST-style JSON and XML payloads in server handler and client proxy.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1052432 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/modules/server/mod-eval.hpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 04d754f249..b8d3147459 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -130,15 +130,21 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>& return mkfailure<int>(reason(val)); const value c = content(val); - // Write returned content-type / content-list pair - if (isList(cadr<value>(c))) + // Write content-type / content-list pair + if (isString(car<value>(c)) && isList(cadr<value>(c))) return httpd::writeResult(convertValues<string>(cadr<value>(c)), car<value>(c), r); - // Write returned ATOM feed or entry - if (isNil(cddr(path))) - return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(c)), "application/atom+xml;type=feed", r); - else - return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(c)), "application/atom+xml;type=entry", r); + // Write ATOM feed or entry + if (isString(car<value>(c)) && isString(cadr<value>(c))) { + if (isNil(cddr(path))) + return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(c)), "application/atom+xml;type=feed", r); + else + return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(c)), "application/atom+xml;type=entry", r); + } + + // Write JSON value + js::JSContext cx; + return httpd::writeResult(json::writeJSON(valuesToElements(c), cx), "application/json", r); } /** |