You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by kxepal <gi...@git.apache.org> on 2015/10/12 19:32:52 UTC

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

GitHub user kxepal opened a pull request:

    https://github.com/apache/couchdb-mem3/pull/16

    Return HTTP 405 for unsupported request method

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kxepal/couchdb-mem3 handle-unsupported-methods

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-mem3/pull/16.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16
    
----
commit 2f503b7719ed127cfa609b2094f68ba8d857a7d3
Author: Alexander Shorin <kx...@apache.org>
Date:   2015-10-12T17:31:00Z

    Return HTTP 405 for unsupported request method

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#discussion_r41782927
  
    --- Diff: src/mem3_httpd.erl ---
    @@ -44,7 +46,12 @@ handle_shards_req(#httpd{method='GET',
         couch_httpd:send_json(Req, {[
             {range, Shard},
             {nodes, Dbs}
    -    ]}).
    +    ]});
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>]}=Req, _Db) ->
    +    chttpd:send_method_not_allowed(Req, "GET");
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>, _DocId]}=Req, _Db) ->
    --- End diff --
    
    Yeah, I understood your reason for two clauses. I guess it's worth the duplication, though until we move to cowboy we're not sending the right errors in many other cases.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-mem3/pull/16


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#issuecomment-147475632
  
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#discussion_r41783142
  
    --- Diff: src/mem3_httpd.erl ---
    @@ -44,7 +46,12 @@ handle_shards_req(#httpd{method='GET',
         couch_httpd:send_json(Req, {[
             {range, Shard},
             {nodes, Dbs}
    -    ]}).
    +    ]});
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>]}=Req, _Db) ->
    +    chttpd:send_method_not_allowed(Req, "GET");
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>, _DocId]}=Req, _Db) ->
    --- End diff --
    
    So cowboy, not webmachine? Cool! Really cool! 
    Meanwhile, I'll try to make a patch for chttpd to handle all unmatched requests and return HTTP 404 instead of HTTP 500. Should help until we move.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#discussion_r41808938
  
    --- Diff: src/mem3_httpd.erl ---
    @@ -44,7 +46,12 @@ handle_shards_req(#httpd{method='GET',
         couch_httpd:send_json(Req, {[
             {range, Shard},
             {nodes, Dbs}
    -    ]}).
    +    ]});
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>]}=Req, _Db) ->
    +    chttpd:send_method_not_allowed(Req, "GET");
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>, _DocId]}=Req, _Db) ->
    --- End diff --
    
    Ok.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#discussion_r41808758
  
    --- Diff: src/mem3_httpd.erl ---
    @@ -44,7 +46,12 @@ handle_shards_req(#httpd{method='GET',
         couch_httpd:send_json(Req, {[
             {range, Shard},
             {nodes, Dbs}
    -    ]}).
    +    ]});
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>]}=Req, _Db) ->
    +    chttpd:send_method_not_allowed(Req, "GET");
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>, _DocId]}=Req, _Db) ->
    --- End diff --
    
    @kxepal I wouldn't spend any more time on that problem right now, let's ship 2.0.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#discussion_r41781652
  
    --- Diff: src/mem3_httpd.erl ---
    @@ -44,7 +46,12 @@ handle_shards_req(#httpd{method='GET',
         couch_httpd:send_json(Req, {[
             {range, Shard},
             {nodes, Dbs}
    -    ]}).
    +    ]});
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>]}=Req, _Db) ->
    +    chttpd:send_method_not_allowed(Req, "GET");
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>, _DocId]}=Req, _Db) ->
    --- End diff --
    
    These not equivalent:
    ```
    http post http://localhost:15984/db/_shards/foo/bar
    HTTP/1.1 500 Internal Server Error
    Cache-Control: must-revalidate
    Content-Length: 70
    Content-Type: text/plain; charset=utf-8
    Date: Mon, 12 Oct 2015 17:40:54 GMT
    Server: CouchDB/0f81930 (Erlang OTP/18)
    X-Couch-Request-ID: 583b8991fd
    X-Couch-Stack-Hash: 2152526230
    X-CouchDB-Body-Time: 0
    
    {"error":"unknown_error","reason":"function_clause","ref":2152526230}
    
    ```
    
    vs
    
    ```
    http post http://localhost:15984/db/_shards/foo/bar
    HTTP/1.1 405 Method Not Allowed
    Allow: GET
    Cache-Control: must-revalidate
    Content-Length: 59
    Content-Type: text/plain; charset=utf-8
    Date: Mon, 12 Oct 2015 17:42:25 GMT
    Server: CouchDB/0f81930 (Erlang OTP/18)
    X-Couch-Request-ID: 08e7452e04
    X-CouchDB-Body-Time: 0
    
    {"error":"method_not_allowed","reason":"Only GET allowed"}
    ```
    
    Technically, we should return HTTP 404 for the first case, not ask to repeat with the GET to fail with HTTP 500 after.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-mem3 pull request: Return HTTP 405 for unsupported request...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-mem3/pull/16#discussion_r41780839
  
    --- Diff: src/mem3_httpd.erl ---
    @@ -44,7 +46,12 @@ handle_shards_req(#httpd{method='GET',
         couch_httpd:send_json(Req, {[
             {range, Shard},
             {nodes, Dbs}
    -    ]}).
    +    ]});
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>]}=Req, _Db) ->
    +    chttpd:send_method_not_allowed(Req, "GET");
    +handle_shards_req(#httpd{path_parts=[_DbName, <<"_shards">>, _DocId]}=Req, _Db) ->
    --- End diff --
    
    do this once with `path_parts=[_DbName, <<"_shards">> | _]` ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---