Web Scripts:

- optionally force status in response header to success regardless of actual status; status in reponse document still reflects actual status
- to support the limitations of Flex runtime without Flex data services
- set alf-force-success-response to true in request header

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5873 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-06-06 22:13:47 +00:00
parent 78342496ab
commit 955db41f51
8 changed files with 93 additions and 18 deletions

View File

@@ -79,6 +79,9 @@ public class TestWebScriptServer
/** Current user */
private String username = "admin";
/** Current headers */
private Map<String, String> headers = new HashMap<String, String>();
/** I18N Messages */
private MessageSource m_messages;
@@ -391,7 +394,9 @@ public class TestWebScriptServer
command[0].equals("delete"))
{
String uri = (command.length > 1) ? command[1] : null;
MockHttpServletResponse res = submitRequest(command[0], uri);
MockHttpServletResponse res = submitRequest(command[0], uri, headers);
bout.write(("Response status: " + res.getStatus()).getBytes());
out.println();
bout.write(res.getContentAsByteArray());
out.println();
}
@@ -414,16 +419,17 @@ public class TestWebScriptServer
{
uri += "&alf:method=" + command[2];
}
MockHttpServletResponse res = submitRequest("post", uri);
MockHttpServletResponse res = submitRequest("post", uri, headers);
bout.write(res.getContentAsByteArray());
out.println();
}
else if (command[1].equals("header"))
{
Map<String, String> headers = new HashMap<String, String>();
headers.put("X-HTTP-Method-Override", command[2]);
MockHttpServletResponse res = submitRequest("post", command[3], headers);
Map<String, String> tunnelheaders = new HashMap<String, String>();
tunnelheaders.putAll(headers);
tunnelheaders.put("X-HTTP-Method-Override", command[2]);
MockHttpServletResponse res = submitRequest("post", command[3], tunnelheaders);
bout.write(res.getContentAsByteArray());
out.println();
}
@@ -434,6 +440,43 @@ public class TestWebScriptServer
}
}
else if (command[0].equals("header"))
{
if (command.length == 1)
{
for (Map.Entry<String, String> entry : headers.entrySet())
{
out.println(entry.getKey() + " = " + entry.getValue());
}
}
else if (command.length == 2)
{
String[] param = command[1].split("=");
if (param.length == 0)
{
return "Syntax Error.\n";
}
if (param.length == 1)
{
headers.remove(param[0]);
out.println("deleted header " + param[0]);
}
else if (param.length == 2)
{
headers.put(param[0], param[1]);
out.println("set header " + param[0] + " = " + headers.get(param[0]));
}
else
{
return "Syntax Error.\n";
}
}
else
{
return "Syntax Error.\n";
}
}
else if (command[0].equals("reset"))
{
registry.reset();