[GitHub] rnewson commented on a change in pull request #605: Add Prefer: return=minimal support

2017-08-09 Thread git
rnewson commented on a change in pull request #605: Add Prefer: return=minimal 
support
URL: https://github.com/apache/couchdb/pull/605#discussion_r132151279
 
 

 ##
 File path: rel/overlay/etc/default.ini
 ##
 @@ -57,6 +57,9 @@ backlog = 512
 docroot = {{fauxton_root}}
 socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
 require_valid_user = false
+; List of headers that will be kept when the header Prefer: return=minimal is 
included in a request.
+; If Server header is left out, Mochiweb will add its own one in.
+; prefer_minimal = Cache-Control, Content-Length, Content-Range, Content-Type, 
ETag, Server, Transfer-Encoding, Vary
 
 Review comment:
   I'm an idiot. I forgot that this is opt-in (you have to pass 'Prefer: 
return=minimal'). So please uncomment this again. :)
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rnewson commented on a change in pull request #605: Add Prefer: return=minimal support

2017-08-09 Thread git
rnewson commented on a change in pull request #605: Add Prefer: return=minimal 
support
URL: https://github.com/apache/couchdb/pull/605#discussion_r132118950
 
 

 ##
 File path: src/chttpd/src/chttpd_prefer_header.erl
 ##
 @@ -0,0 +1,54 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(chttpd_prefer_header).
+
+
+-export([
+maybe_return_minimal/2
+]).
+
+
+-include_lib("couch/include/couch_db.hrl").
+
+
+maybe_return_minimal(#httpd{mochi_req = MochiReq}, Headers) ->
+case get_prefer_header(MochiReq) of
+"return=minimal" -> 
+filter_headers(Headers, get_header_list());
+_ -> 
+Headers
+end.
+
+
+get_prefer_header(Req) ->
+case Req:get_header_value("Prefer") of
+Value when is_list(Value) ->
+string:to_lower(Value);
+undefined -> 
+undefined
+end.
+
+
+filter_headers(Headers, IncludeList) ->
+lists:filter(fun({HeaderName, _}) -> 
+lists:member(HeaderName, IncludeList)
+end, Headers).
+
+
+get_header_list() ->
+SectionStr = config:get("chttpd", "prefer_minimal", []),
 
 Review comment:
   the default needs to be ""?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rnewson commented on a change in pull request #605: Add Prefer: return=minimal support

2017-08-09 Thread git
rnewson commented on a change in pull request #605: Add Prefer: return=minimal 
support
URL: https://github.com/apache/couchdb/pull/605#discussion_r132118717
 
 

 ##
 File path: rel/overlay/etc/default.ini
 ##
 @@ -57,6 +57,9 @@ backlog = 512
 docroot = {{fauxton_root}}
 socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
 require_valid_user = false
+; List of headers that will be kept when the header Prefer: return=minimal is 
included in a request.
+; If Server header is left out, Mochiweb will add its own one in.
+prefer_minimal = Cache-Control, Content-Length, Content-Range, Content-Type, 
ETag, Server, Transfer-Encoding, Vary
 
 Review comment:
   should be commented out by default.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rnewson commented on a change in pull request #605: Add Prefer: return=minimal support

2017-07-31 Thread git
rnewson commented on a change in pull request #605: Add Prefer: return=minimal 
support
URL: https://github.com/apache/couchdb/pull/605#discussion_r130332401
 
 

 ##
 File path: src/chttpd/src/chttpd_prefer_header.erl
 ##
 @@ -0,0 +1,54 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(chttpd_prefer_header).
+
+
+-export([
+maybe_return_minimal/2
+]).
 
 Review comment:
   this line should be at column 0.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rnewson commented on a change in pull request #605: Add Prefer: return=minimal support

2017-07-31 Thread git
rnewson commented on a change in pull request #605: Add Prefer: return=minimal 
support
URL: https://github.com/apache/couchdb/pull/605#discussion_r130332309
 
 

 ##
 File path: rel/overlay/etc/default.ini
 ##
 @@ -57,6 +57,9 @@ backlog = 512
 docroot = {{fauxton_root}}
 socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
 require_valid_user = false
+; List of headers that will be kept when the header Prefer: return=minimal is 
included in a request.
+; If Server header is left out, Mochiweb will add its own one in.
+prefer_minimal = Cache-Control, Content-Length, Content-Type, ETag, Server, 
Vary
 
 Review comment:
   we'll need `Transfer-Encoding` otherwise views, changes, _all_dbs will be 
broken.
   we'll need `Set-Cookie` so we can login.
   what about CORS related headers?
   we'll need `Content-Range` for range reqs on attachments.
   we'll need `WWW-Authenticate` for users that enable the standard login 
prompting setting.
   
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services