Anonymous avatar Anonymous committed 898e569

more useful action on 501 Not Implemented

Comments (0)

Files changed (3)

src/webmachine_error_handler.erl

     ErrorStart = "<html><head><title>500 Internal Server Error</title></head><body><h1>Internal Server Error</h1>The server encountered an error while processing this request:<br><pre>",
     ErrorEnd = "</pre><P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></body></html>",
     ErrorIOList = [ErrorStart,STString,ErrorEnd],
-    erlang:iolist_to_binary(ErrorIOList).
+    erlang:iolist_to_binary(ErrorIOList);
 
+render_error(501, Req, _Reason) ->
+    Req:add_response_header("Content-Type", "text/html"),
+    error_logger:error_msg("Webmachine does not support method ~p~n",
+                           [Req:method()]),
+    ErrorStr = io_lib:format("<html><head><title>501 Not Implemented</title>"
+                             "</head><body><h1>Internal Server Error</h1>"
+                             "The server does not support the ~p method.<br>"
+                             "<P><HR><ADDRESS>mochiweb+webmachine web server"
+                             "</ADDRESS></body></html>",
+                             [Req:method()]),
+    erlang:iolist_to_binary(ErrorStr).
+

src/webmachine_logger.erl

 	    undefined -> "";
 	    U -> U
 	end,
-    fmt_alog(Time, Peer, User, atom_to_list(Method), Path, Version,
+    fmt_alog(Time, Peer, User, fmt_method(Method), Path, Version,
 	     Status, Length, Referer, UserAgent).
 
+fmt_method(M) when is_atom(M) -> atom_to_list(M);
+fmt_method(M) when is_list(M) -> M.
+    
+
 %% Seek backwards to the last valid log entry
 fix_log(_FD, 0) ->
     ok;
     RD#wm_reqdata{path_info=PathInfo,path_tokens=PathTokens,
                  app_root=AppRoot,disp_path=DispPath}.
 
-method(_RD = #wm_reqdata{method=Method}) when is_atom(Method) -> Method.
+method(_RD = #wm_reqdata{method=Method}) -> Method.
 
 version(_RD = #wm_reqdata{version=Version})
   when is_tuple(Version), size(Version) == 2,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.