From 038525403ebcc1d69436adad9bc1cfabb371dae1 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 4 Apr 2011 08:46:08 +0000 Subject: Fix performance and security issues reported by pagespeed and skipfish. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1088508 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/mod-eval.hpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'sca-cpp/trunk/modules/server/mod-eval.hpp') diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 27657dd587..637956321a 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -120,7 +120,7 @@ const failable get(request_rec* r, const lambda&)>& // Return JSON result js::JSContext cx; - return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc", r); + return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc; charset=utf-8", r); } // Evaluate the GET expression @@ -135,14 +135,14 @@ const failable get(request_rec* r, const lambda&)>& if (!isList(c)) { js::JSContext cx; if (isSymbol(c)) - return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("name", value(string(c))))), cx), "application/json", r); - return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("value", c))), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("name", value(string(c))))), cx), "application/json; charset=utf-8", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("value", c))), cx), "application/json; charset=utf-8", r); } // Write an empty list as a JSON empty value if (isNil((list)c)) { js::JSContext cx; - return httpd::writeResult(json::writeJSON(list(), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(list(), cx), "application/json; charset=utf-8", r); } // Write content-type / content-list pair @@ -152,7 +152,7 @@ const failable get(request_rec* r, const lambda&)>& // Write an assoc value as a JSON result if (isSymbol(car(c)) && !isNil(cdr(c))) { js::JSContext cx; - return httpd::writeResult(json::writeJSON(valuesToElements(mklist(c)), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist(c)), cx), "application/json; charset=utf-8", r); } // Convert list of values to element values @@ -164,15 +164,15 @@ const failable get(request_rec* r, const lambda&)>& const list el = car(e); if (isSymbol(car(el)) && car(el) == element && !isNil(cdr(el)) && isSymbol(cadr(el))) { if (cadr(el) == atom::feed) - return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml", r); + return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml; charset=utf-8", r); if (cadr(el) == atom::entry) - return httpd::writeResult(atom::writeATOMEntry(e), "application/atom+xml", r); + return httpd::writeResult(atom::writeATOMEntry(e), "application/atom+xml; charset=utf-8", r); } } // Write any other compound value as a JSON value js::JSContext cx; - return httpd::writeResult(json::writeJSON(e, cx), "application/json", r); + return httpd::writeResult(json::writeJSON(e, cx), "application/json; charset=utf-8", r); } /** @@ -206,7 +206,7 @@ const failable post(request_rec* r, const lambda&)> return mkfailure(reason(val)); // Return JSON result - return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc", r); + return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc; charset=utf-8", r); } // Evaluate an ATOM POST request and return the location of the corresponding created resource @@ -714,6 +714,8 @@ int handler(request_rec *r) { // Get the component implementation lambda const list path(pathValues(r->uri)); + if (isNil(cdr(path))) + return HTTP_NOT_FOUND; const list impl(assoctree(cadr(path), usevh? vhc.vsc.implTree : sc.implTree)); if (isNil(impl)) { mkfailure(string("Couldn't find component implementation: ") + cadr(path)); -- cgit v1.2.3