couchdb-couch-httpd.git
6 years agoRemove iolist_size(Data) == 0 case from send_chunk split_out_httpd_stack
ILYA Khlopotov [Tue, 1 Mar 2016 17:13:56 +0000 (09:13 -0800)] 
Remove iolist_size(Data) == 0 case from send_chunk

This case is handled by start_delayed_response functions.

6 years agoPlug couch_epi
ILYA Khlopotov [Tue, 1 Mar 2016 16:30:11 +0000 (08:30 -0800)] 
Plug couch_epi

6 years agoUse mock since we don't start epi on tests
ILYA Khlopotov [Tue, 1 Mar 2016 16:27:40 +0000 (08:27 -0800)] 
Use mock since we don't start epi on tests

6 years agoFix dispatch to handle_error hook
ILYA Khlopotov [Tue, 1 Mar 2016 16:26:37 +0000 (08:26 -0800)] 
Fix dispatch to handle_error hook

6 years agoExport parse_multipart_request/3 for replicator
ILYA Khlopotov [Mon, 29 Feb 2016 17:44:55 +0000 (09:44 -0800)] 
Export parse_multipart_request/3 for replicator

6 years agoRefactor couch_httpd_config_listener
ILYA Khlopotov [Mon, 29 Feb 2016 17:09:33 +0000 (09:09 -0800)] 
Refactor couch_httpd_config_listener

6 years agoUse functions from couch_httpd app in tests
ILYA Khlopotov [Mon, 29 Feb 2016 17:08:59 +0000 (09:08 -0800)] 
Use functions from couch_httpd app in tests

6 years agoStrip scheme out of Host for cors_section
ILYA Khlopotov [Tue, 16 Feb 2016 23:23:37 +0000 (15:23 -0800)] 
Strip scheme out of Host for cors_section

Value returned by `couch_httpd_vhost:host/1` might not contain scheme.
The cors section is named after vhost name (i.e. without scheme).
For example:

    [cors:partner.com]
    methods =
    headers =
    exposed_headers =
    origins = http://restricted.dev:8000

The origin in origins has to be given with scheme included.

COUCHDB-2945

6 years agoUse cors_config for 'credentials' setting
ILYA Khlopotov [Tue, 16 Feb 2016 23:20:40 +0000 (15:20 -0800)] 
Use cors_config for 'credentials' setting

The 'credentials' setting should be configurable per vhost.

COUCHDB-2945

6 years agoTreat value passed in Origin as case sensitive
ILYA Khlopotov [Tue, 9 Feb 2016 22:41:22 +0000 (14:41 -0800)] 
Treat value passed in Origin as case sensitive

According to CORS spec here https://www.w3.org/TR/cors
The value of the Origin header is not a case-sensitive

COUCHDB-2945

6 years agoIntroduce vhosts configuration into CORS
ILYA Khlopotov [Tue, 9 Feb 2016 21:22:05 +0000 (13:22 -0800)] 
Introduce vhosts configuration into CORS

In order to remove code duplication we move vhosts support
from couch_http_cors into chttpd_cors. We also dispatch
chttpd:send_response to couch_http which does call chttpd_cors:headers.
In order to avoid double injection of CORS headers we check for existance of
"Access-Control-Allow-Origin" in response headers.

COUCHDB-2945

6 years agoSet stack in #httpd_resp{}
ILYA Khlopotov [Fri, 26 Feb 2016 22:01:46 +0000 (14:01 -0800)] 
Set stack in #httpd_resp{}

6 years agoUse Stack to dispatch to correct auth_module
ILYA Khlopotov [Fri, 26 Feb 2016 21:49:17 +0000 (13:49 -0800)] 
Use Stack to dispatch to correct auth_module

6 years agoUse Stack to select http handlers
ILYA Khlopotov [Fri, 26 Feb 2016 21:44:36 +0000 (13:44 -0800)] 
Use Stack to select http handlers

6 years agoExtract get_stack_config/1
ILYA Khlopotov [Fri, 26 Feb 2016 21:32:56 +0000 (13:32 -0800)] 
Extract get_stack_config/1

6 years agoPass Stack to couch_httpd_handler:start_link
ILYA Khlopotov [Fri, 26 Feb 2016 21:32:00 +0000 (13:32 -0800)] 
Pass Stack to couch_httpd_handler:start_link

6 years agoExtract set_socket_options/2 function
ILYA Khlopotov [Fri, 26 Feb 2016 21:24:25 +0000 (13:24 -0800)] 
Extract set_socket_options/2 function

6 years agoPass Stack tuple module to handle_request_int
ILYA Khlopotov [Fri, 26 Feb 2016 21:18:56 +0000 (13:18 -0800)] 
Pass Stack tuple module to handle_request_int

6 years agoMerge differences in catch_error from original
ILYA Khlopotov [Fri, 26 Feb 2016 19:25:37 +0000 (11:25 -0800)] 
Merge differences in catch_error from original

 - catch_error(_HttpReq, exit, normal)
 - catch_error(HttpReq, throw, unacceptable_encoding)
 - catch_error(HttpReq, throw, bad_accept_encoding_value)
 - catch_error(HttpReq, exit, snappy_nif_not_loaded)

6 years agoBring support needed for couch_httpd_rewrite
ILYA Khlopotov [Fri, 26 Feb 2016 19:17:27 +0000 (11:17 -0800)] 
Bring support needed for couch_httpd_rewrite

6 years agoExtract maybe_abort_head_request
ILYA Khlopotov [Fri, 26 Feb 2016 18:40:51 +0000 (10:40 -0800)] 
Extract maybe_abort_head_request

6 years agoExtract maybe_log_response function
ILYA Khlopotov [Fri, 26 Feb 2016 18:38:07 +0000 (10:38 -0800)] 
Extract maybe_log_response function

6 years agoUse basic_headers/2 in serve_file
ILYA Khlopotov [Fri, 26 Feb 2016 18:36:01 +0000 (10:36 -0800)] 
Use basic_headers/2 in serve_file

6 years agoExatract handle_response function
ILYA Khlopotov [Fri, 26 Feb 2016 18:33:22 +0000 (10:33 -0800)] 
Exatract handle_response function

6 years agoExtract add_headers function
ILYA Khlopotov [Fri, 26 Feb 2016 18:25:31 +0000 (10:25 -0800)] 
Extract add_headers function

6 years agoMove module tests
ILYA Khlopotov [Fri, 26 Feb 2016 18:15:34 +0000 (10:15 -0800)] 
Move module tests

6 years agoMerge the diff for send_chunked_error/2
ILYA Khlopotov [Fri, 26 Feb 2016 18:14:45 +0000 (10:14 -0800)] 
Merge the diff for send_chunked_error/2

6 years agoRemove no longer needed function from original
ILYA Khlopotov [Fri, 26 Feb 2016 18:11:51 +0000 (10:11 -0800)] 
Remove no longer needed function from original

6 years agoMerge the diff for send_error/2 and send_error/4
ILYA Khlopotov [Fri, 26 Feb 2016 18:11:17 +0000 (10:11 -0800)] 
Merge the diff for send_error/2 and send_error/4

6 years agoMerge the diff for error_info/1
ILYA Khlopotov [Fri, 26 Feb 2016 18:06:30 +0000 (10:06 -0800)] 
Merge the diff for error_info/1

6 years agoMerge the diff for verify_is_server_admin/1
ILYA Khlopotov [Fri, 26 Feb 2016 17:58:07 +0000 (09:58 -0800)] 
Merge the diff for verify_is_server_admin/1

6 years agoBring validate_bind_address/1 from original
ILYA Khlopotov [Fri, 26 Feb 2016 17:55:27 +0000 (09:55 -0800)] 
Bring validate_bind_address/1 from original

6 years agoRemove no longer need function from original
ILYA Khlopotov [Fri, 26 Feb 2016 17:53:31 +0000 (09:53 -0800)] 
Remove no longer need function from original

6 years agoBring validate_referer/1 from original
ILYA Khlopotov [Fri, 26 Feb 2016 17:52:55 +0000 (09:52 -0800)] 
Bring validate_referer/1 from original

6 years agoBring accepted_encodings/1 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:58:12 +0000 (11:58 -0800)] 
Bring accepted_encodings/1 from original

6 years agoBring validate_host/1 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:55:20 +0000 (11:55 -0800)] 
Bring validate_host/1 from original

6 years agoMerge start_chunked_response/3 and send_response/4
ILYA Khlopotov [Thu, 25 Feb 2016 19:52:34 +0000 (11:52 -0800)] 
Merge start_chunked_response/3 and send_response/4

6 years agoBring etag_maybe/2 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:42:46 +0000 (11:42 -0800)] 
Bring etag_maybe/2 from original

6 years agoMerge the diff for send_chunk/2
ILYA Khlopotov [Thu, 25 Feb 2016 19:40:02 +0000 (11:40 -0800)] 
Merge the diff for send_chunk/2

6 years agoMerge the diff for start_response_length/4
ILYA Khlopotov [Thu, 25 Feb 2016 19:27:35 +0000 (11:27 -0800)] 
Merge the diff for start_response_length/4

6 years agoBring start_response/3 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:25:32 +0000 (11:25 -0800)] 
Bring start_response/3 from original

6 years agoRemove equivalent copy of etag_match/2 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:13:57 +0000 (11:13 -0800)] 
Remove equivalent copy of etag_match/2 from original

6 years agoRemove equivalent copy of etag_respond/3 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:12:27 +0000 (11:12 -0800)] 
Remove equivalent copy of etag_respond/3 from original

6 years agoMove parse_multipart_request/3 into couch_httpd_multipart
ILYA Khlopotov [Thu, 25 Feb 2016 19:10:18 +0000 (11:10 -0800)] 
Move parse_multipart_request/3 into couch_httpd_multipart

6 years agoBring log_request/2 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:06:48 +0000 (11:06 -0800)] 
Bring log_request/2 from original

6 years agoRemove equivalent copy of maybe_decompress/1 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:03:48 +0000 (11:03 -0800)] 
Remove equivalent copy of maybe_decompress/1 from original

6 years agoRemove equivalent copy of body/1 from original
ILYA Khlopotov [Thu, 25 Feb 2016 19:02:11 +0000 (11:02 -0800)] 
Remove equivalent copy of body/1 from original

6 years agoConvert case into clause for body/1 as in original
ILYA Khlopotov [Thu, 25 Feb 2016 19:01:02 +0000 (11:01 -0800)] 
Convert case into clause for body/1 as in original

6 years agoRemove exact copy of absolute_uri/2 from original
ILYA Khlopotov [Thu, 25 Feb 2016 18:57:00 +0000 (10:57 -0800)] 
Remove exact copy of absolute_uri/2 from original

6 years agoExtract host_for_request/1 as it is done in original
ILYA Khlopotov [Thu, 25 Feb 2016 18:55:02 +0000 (10:55 -0800)] 
Extract host_for_request/1 as it is done in original

6 years agoRemove exact duplicates of functions from original
ILYA Khlopotov [Thu, 25 Feb 2016 18:49:11 +0000 (10:49 -0800)] 
Remove exact duplicates of functions from original

There are functions which we already have in new version of couch_httpd.
Therefore we remove them from original to better track refactoring
progress.

Following functions has been removed:

 - validate_ctype/2
 - header_value/2
 - header_value/3
 - qs_value/2
 - qs_value/3
 - qs/1
 - qs_json_value/3
 - path/1
 - body_length/1
 - unquote/1
 - quote/1
 - recv/2
 - recv_chunked/4
 - json_body/1
 - json_body_obj/1
 - parse_form/1
 - doc_etag/1
 - make_etag/1
 - primary_header_value/2
 - partition/1
 - serve_file/3
 - serve_file/4
 - send/2
 - send_method_not_allowed/2
 - send_redirect/2

6 years agoFix places where we call itself (couch_httpd)
ILYA Khlopotov [Thu, 25 Feb 2016 18:30:27 +0000 (10:30 -0800)] 
Fix places where we call itself (couch_httpd)

When we renamed chttpd -> couch_httpd we had places where
we dispatch to original implementation of couch_httpd. We move missing
functions from couch_httpd_original into couch_httpd.

The following functions has been moved:

 - last_chunk/1
 - start_json_response/3
 - send_json/3
 - end_json_response/2
 - validate_ctype/2
 - server_header/0

6 years agoGroup functions and exports
ILYA Khlopotov [Wed, 24 Feb 2016 17:22:08 +0000 (09:22 -0800)] 
Group functions and exports

This is just a cosmetic commit. Without any change to functionality.

6 years agoExtract ssl_options/0
ILYA Khlopotov [Wed, 24 Feb 2016 16:45:13 +0000 (08:45 -0800)] 
Extract ssl_options/0

6 years ago[fixup] Use couch_httpd_util:fun_from_spec/2
ILYA Khlopotov [Wed, 24 Feb 2016 16:42:16 +0000 (08:42 -0800)] 
[fixup] Use couch_httpd_util:fun_from_spec/2

6 years ago[fixup] Refactor make_arity_N_fun into fun_from_spec/2
ILYA Khlopotov [Wed, 24 Feb 2016 16:38:22 +0000 (08:38 -0800)] 
[fixup] Refactor make_arity_N_fun into fun_from_spec/2

6 years agoMove make_arity_N_fun into couch_httpd_util
ILYA Khlopotov [Wed, 24 Feb 2016 16:36:41 +0000 (08:36 -0800)] 
Move make_arity_N_fun into couch_httpd_util

6 years ago[fixup] Use functions from couch_httpd module
ILYA Khlopotov [Wed, 24 Feb 2016 16:11:33 +0000 (08:11 -0800)] 
[fixup] Use functions from couch_httpd module

 - quote/1
 - unquote/1
 - header_value/3
 - send_error/2
 - send_error/6

6 years agoMove some functions to couch_httpd_handler
ILYA Khlopotov [Wed, 24 Feb 2016 16:03:20 +0000 (08:03 -0800)] 
Move some functions to couch_httpd_handler

 - start_link/0
 - start_link/1
 - start_link/2
 - stop/0

 - handle_request/1
 - handle_request_int/1

 - authenticate_request/3

6 years ago[fixup] couch_httpd_cors.hrl
ILYA Khlopotov [Wed, 24 Feb 2016 16:06:07 +0000 (08:06 -0800)] 
[fixup] couch_httpd_cors.hrl

6 years ago[fixup] Update references to renamed headers file
ILYA Khlopotov [Wed, 24 Feb 2016 15:48:42 +0000 (07:48 -0800)] 
[fixup] Update references to renamed headers file

 - sed -i -e 's|chttpd/include/chttpd_cors.hrl|couch_httpd/include/couch_httpd_cors.hrl|g'

6 years agoRename chttpd_cors.hrl into couch_httpd_cors.hrl
ILYA Khlopotov [Wed, 24 Feb 2016 15:26:15 +0000 (07:26 -0800)] 
Rename chttpd_cors.hrl into couch_httpd_cors.hrl

6 years ago[fixup] Update references to renamed headers file
ILYA Khlopotov [Wed, 24 Feb 2016 15:47:09 +0000 (07:47 -0800)] 
[fixup] Update references to renamed headers file

 - sed -i -e 's|chttpd/include/chttpd.hrl|couch_httpd/include/couch_httpd.hrl|g'

6 years agoRename chttpd.hrl into couch_httpd.hrl
ILYA Khlopotov [Wed, 24 Feb 2016 15:25:33 +0000 (07:25 -0800)] 
Rename chttpd.hrl into couch_httpd.hrl

6 years agoRename chttpd_rewrite into couch_httpd_rewrite
ILYA Khlopotov [Wed, 24 Feb 2016 15:23:04 +0000 (07:23 -0800)] 
Rename chttpd_rewrite into couch_httpd_rewrite

6 years ago[fixup] Update references to chttpd_external
ILYA Khlopotov [Mon, 29 Feb 2016 17:10:32 +0000 (09:10 -0800)] 
[fixup] Update references to chttpd_external

6 years agoRename chttpd_external into couch_httpd_external
ILYA Khlopotov [Wed, 24 Feb 2016 15:22:02 +0000 (07:22 -0800)] 
Rename chttpd_external into couch_httpd_external

6 years ago[fixup] Update references to renamed module
ILYA Khlopotov [Wed, 24 Feb 2016 15:44:49 +0000 (07:44 -0800)] 
[fixup] Update references to renamed module

 - sed -i -e 's|chttpd_handlers:|couch_httpd_handlers:|g'

6 years agoRename chttpd_handlers into couch_httpd_handlers
ILYA Khlopotov [Wed, 24 Feb 2016 15:20:33 +0000 (07:20 -0800)] 
Rename chttpd_handlers into couch_httpd_handlers

6 years agoRename chttpd_config_listener into couch_httpd_config_listener
ILYA Khlopotov [Wed, 24 Feb 2016 15:19:12 +0000 (07:19 -0800)] 
Rename chttpd_config_listener into couch_httpd_config_listener

6 years ago[fixup] Update references to renamed module
ILYA Khlopotov [Wed, 24 Feb 2016 15:42:42 +0000 (07:42 -0800)] 
[fixup] Update references to renamed module

 - sed -i -e 's|chttpd_auth:|couch_httpd_auth_plugin:|g'

6 years agoRename chttpd_auth into couch_httpd_auth_plugin
ILYA Khlopotov [Wed, 24 Feb 2016 15:11:25 +0000 (07:11 -0800)] 
Rename chttpd_auth into couch_httpd_auth_plugin

6 years agoRename chttpd_error_info_tests into couch_httpd_error_info_test
ILYA Khlopotov [Wed, 24 Feb 2016 15:09:53 +0000 (07:09 -0800)] 
Rename chttpd_error_info_tests into couch_httpd_error_info_test

6 years ago[fixup] Update path to couch_httpd_cors.hrl
ILYA Khlopotov [Mon, 29 Feb 2016 17:06:08 +0000 (09:06 -0800)] 
[fixup] Update path to couch_httpd_cors.hrl

6 years agoRename chttpd_cors_test into couch_httpd_cors_test
ILYA Khlopotov [Wed, 24 Feb 2016 15:08:34 +0000 (07:08 -0800)] 
Rename chttpd_cors_test into couch_httpd_cors_test

6 years ago[fixup] Update references to renamed module
ILYA Khlopotov [Wed, 24 Feb 2016 15:40:01 +0000 (07:40 -0800)] 
[fixup] Update references to renamed module

 - sed -i -e 's|chttpd_plugin:|couch_httpd_plugin:|g'

6 years agoChange SERVICE_ID chttpd -> couch_httpd
ILYA Khlopotov [Fri, 26 Feb 2016 23:48:48 +0000 (15:48 -0800)] 
Change SERVICE_ID chttpd -> couch_httpd

6 years agoRename chttpd_plugin into couch_httpd_plugin
ILYA Khlopotov [Wed, 24 Feb 2016 15:07:05 +0000 (07:07 -0800)] 
Rename chttpd_plugin into couch_httpd_plugin

6 years ago[fixup] Update references to renamed module
ILYA Khlopotov [Wed, 24 Feb 2016 15:38:22 +0000 (07:38 -0800)] 
[fixup] Update references to renamed module

 - sed -i -e 's|chttpd_cors:|couch_httpd_cors:|g'

6 years agoRename chttpd_cors into couch_httpd_cors
ILYA Khlopotov [Wed, 24 Feb 2016 15:04:53 +0000 (07:04 -0800)] 
Rename chttpd_cors into couch_httpd_cors

6 years ago[fixup] Update references to renamed module
ILYA Khlopotov [Wed, 24 Feb 2016 15:36:08 +0000 (07:36 -0800)] 
[fixup] Update references to renamed module

 - sed -i -e 's|-import(chttpd|-import(couch_httpd|g'
 - sed -i -e 's|chttpd:|couch_httpd:|g'

6 years agoRename chttpd into couch_httpd
ILYA Khlopotov [Wed, 24 Feb 2016 15:03:33 +0000 (07:03 -0800)] 
Rename chttpd into couch_httpd

6 years agoDepend on couch_epi and config
ILYA Khlopotov [Fri, 26 Feb 2016 23:42:51 +0000 (15:42 -0800)] 
Depend on couch_epi and config

6 years agoRename couch_httpd into couch_httpd_original
ILYA Khlopotov [Wed, 24 Feb 2016 15:02:19 +0000 (07:02 -0800)] 
Rename couch_httpd into couch_httpd_original

6 years agoUpdate app description
ILYA Khlopotov [Tue, 1 Mar 2016 16:30:23 +0000 (08:30 -0800)] 
Update app description

6 years agoMove files we need from chttpd app as is
ILYA Khlopotov [Tue, 23 Feb 2016 17:04:13 +0000 (09:04 -0800)] 
Move files we need from chttpd app as is

6 years agoMove files we need from couch app as is
ILYA Khlopotov [Tue, 23 Feb 2016 17:03:26 +0000 (09:03 -0800)] 
Move files we need from couch app as is

6 years agoAdd app file
ILYA Khlopotov [Tue, 23 Feb 2016 17:03:12 +0000 (09:03 -0800)] 
Add app file

6 years agoMerge remote-tracking branch 'github/pr/100'
Alexander Shorin [Tue, 2 Feb 2016 15:23:06 +0000 (18:23 +0300)] 
Merge remote-tracking branch 'github/pr/100'

6 years agoConvert all CORS headers config into lowercase
ILYA Khlopotov [Thu, 28 Jan 2016 23:39:30 +0000 (15:39 -0800)] 
Convert all CORS headers config into lowercase

6 years agoAdding more tests for CORS
ILYA Khlopotov [Mon, 25 Jan 2016 21:07:19 +0000 (13:07 -0800)] 
Adding more tests for CORS

6 years agoIntroduce cors/exposed_headers config setting
ILYA Khlopotov [Mon, 25 Jan 2016 21:06:39 +0000 (13:06 -0800)] 
Introduce cors/exposed_headers config setting

6 years agoMake use of <<allow_headers>> option
ILYA Khlopotov [Mon, 25 Jan 2016 21:05:47 +0000 (13:05 -0800)] 
Make use of <<allow_headers>> option

6 years agoUse correct setting for AllowHeaders
ILYA Khlopotov [Mon, 25 Jan 2016 21:04:06 +0000 (13:04 -0800)] 
Use correct setting for AllowHeaders

6 years agoDon't crash on unknown request method
Alexander Shorin [Sun, 3 Jan 2016 17:17:29 +0000 (20:17 +0300)] 
Don't crash on unknown request method

6 years agoAsk cassim for secObj value
Alexander Shorin [Wed, 18 Nov 2015 18:37:41 +0000 (21:37 +0300)] 
Ask cassim for secObj value

6 years agoRewrite via query server
ermouth [Fri, 2 Oct 2015 11:00:53 +0000 (14:00 +0300)] 
Rewrite via query server

COUCHDB-2874

6 years agoExpose couch_js_functions to other apps
Robert Newson [Sun, 20 Dec 2015 18:14:35 +0000 (18:14 +0000)] 
Expose couch_js_functions to other apps

COUCHDB-2082

6 years agoMerge branch '1.x-compat'
Jan Lehnardt [Fri, 18 Dec 2015 10:51:09 +0000 (11:51 +0100)] 
Merge branch '1.x-compat'

* 1.x-compat:
  1.x compat: update fun: allow docs with slash in id
  1.x compat: parse form data for externals on PUT in addtion ot POST

6 years ago1.x compat: parse form data for externals on PUT in addtion ot POST
Jan Lehnardt [Sat, 12 Dec 2015 14:09:01 +0000 (15:09 +0100)] 
1.x compat: parse form data for externals on PUT in addtion ot POST