You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by iilyak <gi...@git.apache.org> on 2016/01/25 22:30:18 UTC

[GitHub] couchdb-chttpd pull request: Improve cors support

GitHub user iilyak opened a pull request:

    https://github.com/apache/couchdb-chttpd/pull/100

    Improve cors support

    This PR makes it possible to configure CORS to be able to use custom headers.
    It mostly fixes already existing code. The only new addition is `exposed_headers` setting.
    
    The supported configuration is via `default.ini`:
    ```ini
    [cors]
    headers = "content-type, accept-ranges, ..."
    methods = "COPY, DELETE, ...."
    exposed_headers = "extra, accept-ranges, etag, server, ..."
    ```

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

    $ git pull https://github.com/cloudant/couchdb-chttpd improve_cors_support

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

    https://github.com/apache/couchdb-chttpd/pull/100.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 #100
    
----
commit 9733d21ac223fbe92fc94405ef9d33c919aaa8ad
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Date:   2016-01-25T21:04:06Z

    Use correct setting for AllowHeaders

commit 63af9339f2a65125e2e14498e3b985b915115004
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Date:   2016-01-25T21:05:47Z

    Make use of <<allow_headers>> option

commit 5a1f6602829af61a336789e30debfe7bf0209c04
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Date:   2016-01-25T21:06:39Z

    Introduce cors/exposed_headers config setting

commit f59f4a9598924489dc7b0cf796aefc2bdc32c8f7
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Date:   2016-01-25T21:07:19Z

    Adding more tests for CORS

----


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176930716
  
    Too late, the harm has been done. :older_man:
    
    This looks good, again: +1 after squash


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#discussion_r51142280
  
    --- Diff: src/chttpd_cors.erl ---
    @@ -176,15 +180,15 @@ headers(Req, RequestHeaders, Origin, Config) ->
             true ->
                 AcceptedOrigins = get_accepted_origins(Req, Config),
                 CorsHeaders = handle_headers(Config, Origin, AcceptedOrigins),
    -            maybe_apply_headers(CorsHeaders, RequestHeaders);
    +            maybe_apply_headers(Config, CorsHeaders, RequestHeaders);
    --- End diff --
    
    Personally I'd get `exposed_headers` out of config on a line above to make input parameters in `maybe_apply_headers` consistent to be all headers, but this is a question of a personal taste, so feel free to ignore.


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176254081
  
    @eiri I think that's not good to ask write methods in upper case and headers in lower one. Users who read the spec knows that header names are case insensitive, so it's not what they expect from us here. Reference to the docs wouldn't work here....well, it will, but after someone waste his time on debug.
    
    Can we take the responsibility for headers names normalization from user to our code? 


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176916598
  
    @iilyak Thank you!
    @eiri Does the latest changes works for your test app? Without grey hair now I guess? (:


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176947068
  
    Once Eric was just Eric, but now he'll be known as Eric the Grey! P:
    Good to know, will trust you here as I'm not good with CORS thing. Looks good for me as well. +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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176249331
  
    A note: config parameters for `headers` and `exposed_headers` **have to** be in lower case and it's notoriously hard to figure out, browser will just keep telling that OPTION throws 401 error code.
    
    We'd better to reflect this in documentation to protect users.


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176428919
  
    @eiri sounds good!


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176247928
  
    All right, that took some effort to test, I've ended up writing a simple CORS app, but now I'm sure this is working as advertised. 
    
    +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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176937898
  
    Squashed.


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100


---
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-chttpd pull request: Improve cors support

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

    https://github.com/apache/couchdb-chttpd/pull/100#issuecomment-176260200
  
    @kxepal Well, you right, I guess we can do `[string:to_lower(H) || H <- split_list(Headers0)]` for `AllowMethods` and `ExposedHeaders`, that'd save someone from some grey hair.


---
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.
---