Throw any exceptions thrown unwrapped. This way, the caller knows what it's dealing...
[pithos] / src / gr / ebs / gss / server / rest / RequestHandler.java
index 12a7f06..1b13c1d 100644 (file)
@@ -450,7 +450,7 @@ public class RequestHandler extends Webdav {
             resp.addHeader("Allow", methodsAllowed.get(PATH_SEARCH));
                        resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
                } else if (path.startsWith(PATH_USERS)) {
-            resp.addHeader("Allow", methodsAllowed.get(PATH_USERS));
+                       resp.addHeader("Allow", methodsAllowed.get(PATH_USERS));
                        resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
                } else if (path.startsWith(PATH_SHARED)) {
             resp.addHeader("Allow", methodsAllowed.get(PATH_SHARED));
@@ -465,6 +465,8 @@ public class RequestHandler extends Webdav {
                        resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
                } else if (path.startsWith(PATH_FILES))
                        new FilesHandler(getServletContext()).postResource(req, resp);
+               else if (path.equals("/"))
+                       new UserHandler().postUser(req, resp);
                else
                resp.sendError(HttpServletResponse.SC_NOT_FOUND, req.getRequestURI());
        }
@@ -532,7 +534,7 @@ public class RequestHandler extends Webdav {
        writer.write(json);
        writer.flush();
 
-       resp.setContentType("text/html;charset=UTF-8");
+       resp.setContentType("application/json;charset=UTF-8");
        resp.setBufferSize(output);
                try {
                        copy(null, new ByteArrayInputStream(stream.toByteArray()), resp.getOutputStream(), req, null);
@@ -606,6 +608,8 @@ public class RequestHandler extends Webdav {
 
                // Fetch the Authorization header and find the user specified in it.
                String auth = request.getHeader(AUTHORIZATION_HEADER);
+               if (auth == null)
+                       return false;
                String[] authParts = auth.split(" ");
                if (authParts.length != 2)
                        return false;