You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by cm...@apache.org on 2008/05/26 11:20:48 UTC

svn commit: r660139 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Author: cmlenz
Date: Mon May 26 02:20:47 2008
New Revision: 660139

URL: http://svn.apache.org/viewvc?rev=660139&view=rev
Log:
Change error handling on unknown private paths to be more consistent with how other errors are handled.

Modified:
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=660139&r1=660138&r2=660139&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Mon May 26 02:20:47 2008
@@ -99,8 +99,8 @@
             {ok, Req:respond({301, [{"Location", "/_utils/"}], <<>>})};
         "/_utils/" ++ PathInfo ->
             {ok, Req:serve_file(PathInfo, DocumentRoot)};
-        "/_" ++ UnknownPrivatePath ->
-            handle_unkown_private_uri_request(Req, Method, UnknownPrivatePath);
+        "/_" ++ _Path ->
+            throw({not_found, unknown_private_path});
         _Else ->
             handle_db_request(Req, Method, {Path})
     end.
@@ -134,18 +134,6 @@
 handle_replicate_request(_Req, _Method) ->
     throw({method_not_allowed, "POST"}).
 
-handle_unkown_private_uri_request(Req, _Method, UnknownPrivatePath) ->
-  KnownPrivatePaths = ["_utils"],
-  Msg = {obj,
-    [
-      {error, "Could not find the private path '_" ++
-        mochiweb_util:unquote(UnknownPrivatePath) ++
-        "'. Known private path(s): '" ++
-        lists:flatten(KnownPrivatePaths) ++ "'"}
-    ]
-  },
-  send_error(Req, 404, Msg).
-
 % Database request handlers
 
 handle_db_request(Req, Method, {Path}) ->



Re: svn commit: r660139 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Posted by Noah Slater <ns...@apache.org>.
On Mon, May 26, 2008 at 12:08:33PM +0200, Jan Lehnardt wrote:
> If the other's out-vote me, I  shall shut up about this :)

FWIW, I think I agree with Chris on this.

-- 
Noah Slater - The Apache Software Foundation <http://www.apache.org/>

Re: svn commit: r660139 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Posted by Jan Lehnardt <ja...@apache.org>.
On May 26, 2008, at 12:03, Christopher Lenz wrote:

> Hey Jan,
>
> On 26.05.2008, at 11:28, Jan Lehnardt wrote:
>> On May 26, 2008, at 11:20, cmlenz@apache.org wrote:
>>> Author: cmlenz
>>> Date: Mon May 26 02:20:47 2008
>>> New Revision: 660139
>>>
>>> URL: http://svn.apache.org/viewvc?rev=660139&view=rev
>>> Log:
>>> Change error handling on unknown private paths to be more  
>>> consistent with how other errors are handled.
>>
>> This was a deliberate derivation from the error
>> handling to be more user-friendly. That is, directly
>> show the user that they meant "/_utils" when they
>> tried "/_util".
>
> I understand that, but I think this is a slippery slope, and it *is*  
> a deviation :)
>
> First, there are other "private paths" (not sure that's even a good  
> name): /_all_dbs, /_compact, /_search, /_replicate. So even this  
> early in the process we've forgotten to add quite a number of URLs  
> to the list of "known private paths". And as long as the URL mapping  
> is not dynamic/modular, we'll have to remember to keep the list in  
> sync with the URLs actually in use.
>
> Second, where do you stop? You could argue the same about special  
> URLs in the database namespace: /_view, /_design, /_all_docs, etc.
>
> Finally, is it really that hard to remember that it's "/_utils" and  
> not "/_util"? Or just try the former after the latter failed? :P
>
>> with the advent of customizable private paths, I though
>> this a valuable addition.
>
> But that's not there yet. I'd rather wait until it's in place (or we  
> have a better idea about the design) until designing special error  
> messages with that feature in mind.
>
> But of course I can back out the change if you don't agree with any  
> of my arguments, it's not such a big deal anyway :)

I do agree with your arguments ;) but in the special
case of _util and _utils I think it is worth it to go the
extra mile and make the user happy.

If the other's out-vote me, I  shall shut up about this :)

Cheers
Jan
--


> Cheers,
> --
> Christopher Lenz
>  cmlenz at gmx.de
>  http://www.cmlenz.net/
>
>


Re: svn commit: r660139 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Posted by Christopher Lenz <cm...@gmx.de>.
Hey Jan,

On 26.05.2008, at 11:28, Jan Lehnardt wrote:
> On May 26, 2008, at 11:20, cmlenz@apache.org wrote:
>> Author: cmlenz
>> Date: Mon May 26 02:20:47 2008
>> New Revision: 660139
>>
>> URL: http://svn.apache.org/viewvc?rev=660139&view=rev
>> Log:
>> Change error handling on unknown private paths to be more  
>> consistent with how other errors are handled.
>
> This was a deliberate derivation from the error
> handling to be more user-friendly. That is, directly
> show the user that they meant "/_utils" when they
> tried "/_util".

I understand that, but I think this is a slippery slope, and it *is* a  
deviation :)

First, there are other "private paths" (not sure that's even a good  
name): /_all_dbs, /_compact, /_search, /_replicate. So even this early  
in the process we've forgotten to add quite a number of URLs to the  
list of "known private paths". And as long as the URL mapping is not  
dynamic/modular, we'll have to remember to keep the list in sync with  
the URLs actually in use.

Second, where do you stop? You could argue the same about special URLs  
in the database namespace: /_view, /_design, /_all_docs, etc.

Finally, is it really that hard to remember that it's "/_utils" and  
not "/_util"? Or just try the former after the latter failed? :P

> with the advent of customizable private paths, I though
> this a valuable addition.

But that's not there yet. I'd rather wait until it's in place (or we  
have a better idea about the design) until designing special error  
messages with that feature in mind.

But of course I can back out the change if you don't agree with any of  
my arguments, it's not such a big deal anyway :)

Cheers,
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


Re: svn commit: r660139 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Posted by Jan Lehnardt <ja...@apache.org>.
On May 26, 2008, at 11:20, cmlenz@apache.org wrote:

> Author: cmlenz
> Date: Mon May 26 02:20:47 2008
> New Revision: 660139
>
> URL: http://svn.apache.org/viewvc?rev=660139&view=rev
> Log:
> Change error handling on unknown private paths to be more consistent  
> with how other errors are handled.

This was a deliberate derivation from the error
handling to be more user-friendly. That is, directly
show the user that they meant "/_utils" when they
tried "/_util".

with the advent of customizable private paths, I though
this a valuable addition.

>
>
> Modified:
>    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
>
> Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
> URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=660139&r1=660138&r2=660139&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
> +++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Mon May 26  
> 02:20:47 2008
> @@ -99,8 +99,8 @@
>             {ok, Req:respond({301, [{"Location", "/_utils/"}],  
> <<>>})};
>         "/_utils/" ++ PathInfo ->
>             {ok, Req:serve_file(PathInfo, DocumentRoot)};
> -        "/_" ++ UnknownPrivatePath ->
> -            handle_unkown_private_uri_request(Req, Method,  
> UnknownPrivatePath);
> +        "/_" ++ _Path ->
> +            throw({not_found, unknown_private_path});
>         _Else ->
>             handle_db_request(Req, Method, {Path})
>     end.
> @@ -134,18 +134,6 @@
> handle_replicate_request(_Req, _Method) ->
>     throw({method_not_allowed, "POST"}).
>
> -handle_unkown_private_uri_request(Req, _Method, UnknownPrivatePath)  
> ->
> -  KnownPrivatePaths = ["_utils"],
> -  Msg = {obj,
> -    [
> -      {error, "Could not find the private path '_" ++
> -        mochiweb_util:unquote(UnknownPrivatePath) ++
> -        "'. Known private path(s): '" ++
> -        lists:flatten(KnownPrivatePaths) ++ "'"}
> -    ]
> -  },
> -  send_error(Req, 404, Msg).
> -
> % Database request handlers
>
> handle_db_request(Req, Method, {Path}) ->
>
>
>