From c06d7a38b904247917462c3c1a780f95c68e0709 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sat, 30 Jan 2010 08:06:00 +0000 Subject: Added a Web service listener component integrating Axis2/C's mod_axis2. Consolidated a bit the HTTPD redirect functions (used to redirect to mod_axis2.) Minor updates to the README and INSTALL files. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@904733 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/mod-eval.hpp | 36 +++++++++++++++++++---------- sca-cpp/trunk/modules/server/mod-wiring.cpp | 20 +++------------- 2 files changed, 27 insertions(+), 29 deletions(-) (limited to 'sca-cpp/trunk/modules/server') diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index aaf31f2b18..b622283fed 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -129,13 +129,18 @@ const failable get(request_rec* r, const lambda&)>& * Handle an HTTP POST. */ const failable post(request_rec* r, const lambda&)>& impl) { - const list ls = httpd::read(r); debug(r->uri, "modeval::post::url"); - debug(ls, "modeval::post::input"); // Evaluate a JSON-RPC request and return a JSON result const string ct = httpd::contentType(r); if (contains(ct, "application/json-rpc") || contains(ct, "text/plain")) { + + // Read the JSON request + const int rc = httpd::setupReadPolicy(r); + if(rc != OK) + return rc; + const list ls = httpd::read(r); + debug(ls, "modeval::post::input"); json::JSONContext cx; const list json = elementsToValues(content(json::readJSON(ls, cx))); const list > args = httpd::postArgs(json); @@ -157,8 +162,15 @@ const failable post(request_rec* r, const lambda&)> // Evaluate an ATOM POST request and return the location of the corresponding created resource if (contains(ct, "application/atom+xml")) { - // Evaluate the request expression + // Read the ATOM entry + const int rc = httpd::setupReadPolicy(r); + if(rc != OK) + return rc; + const list ls = httpd::read(r); + debug(ls, "modeval::post::input"); const value entry = atom::entryValue(content(atom::readEntry(ls))); + + // Evaluate the request expression const failable val = failableResult(impl(cons("post", mklist(entry)))); if (!hasContent(val)) return mkfailure(reason(val)); @@ -174,20 +186,25 @@ const failable post(request_rec* r, const lambda&)> const failable val = failableResult(impl(cons("handle", mklist(httpd::requestValue(r))))); if (!hasContent(val)) return mkfailure(reason(val)); - return OK; + return (int)content(val); } /** * Handle an HTTP PUT. */ const failable put(request_rec* r, const lambda&)>& impl) { - const list ls = httpd::read(r); debug(r->uri, "modeval::put::url"); - debug(ls, "modeval::put::input"); - // Evaluate an ATOM PUT request and update the corresponding resource + // Read the ATOM entry const list path(httpd::pathValues(r->uri)); + const int rc = httpd::setupReadPolicy(r); + if(rc != OK) + return rc; + const list ls = httpd::read(r); + debug(ls, "modeval::put::input"); const value entry = atom::entryValue(content(atom::readEntry(ls))); + + // Evaluate the ATOM PUT request and update the corresponding resource const failable val = failableResult(impl(cons("put", mklist(caddr(path), entry)))); if (!hasContent(val)) return mkfailure(reason(val)); @@ -244,11 +261,6 @@ int handler(request_rec *r) { return DECLINED; httpdDebugRequest(r, "modeval::handler::input"); - // Set up the read policy - const int rc = httpd::setupReadPolicy(r); - if(rc != OK) - return rc; - // Get the component implementation lambda DirConf& dc = httpd::dirConf(r, &mod_tuscany_eval); const list path(httpd::pathValues(r->uri)); diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp index 88a57659ef..aef2f00c83 100644 --- a/sca-cpp/trunk/modules/server/mod-wiring.cpp +++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp @@ -193,17 +193,6 @@ int translate(request_rec *r) { return translateService(r); } -/** - * Construct a redirect URI. - */ -const string redirect(const string& file, const string& pi) { - return file + pi; -} - -const string redirect(const string& file, const string& pi, const string& args) { - return file + pi + "?" + args; -} - /** * HTTP request handler, redirect to a target component. */ @@ -220,12 +209,9 @@ int handler(request_rec *r) { debug(r->filename, "modwiring::handler::filename"); debug(r->path_info, "modwiring::handler::path info"); - if (r->args == NULL) { - ap_internal_redirect(apr_pstrdup(r->pool, c_str(redirect(string(r->filename + 10), string(r->path_info)))), r); - return OK; - } - ap_internal_redirect(apr_pstrdup(r->pool, c_str(redirect(string(r->filename + 10), string(r->path_info), string(r->args)))), r); - return OK; + if (r->args == NULL) + return httpd::internalRedirect(httpd::redirectURI(string(r->filename + 10), string(r->path_info)), r); + return httpd::internalRedirect(httpd::redirectURI(string(r->filename + 10), string(r->path_info), string(r->args)), r); } /** -- cgit v1.2.3