Robert Kowalski [Thu, 27 Aug 2015 13:34:30 +0000 (15:34 +0200)]
fix intendation
Robert Kowalski [Tue, 25 Aug 2015 13:45:43 +0000 (15:45 +0200)]
readd errors for tbd view compaction
Robert Kowalski [Mon, 24 Aug 2015 09:34:20 +0000 (11:34 +0200)]
changes from review
Robert Kowalski [Fri, 21 Aug 2015 12:13:18 +0000 (14:13 +0200)]
add clusterwide compaction for dbs
COUCHDB-2492
Alexander Shorin [Wed, 19 Aug 2015 19:12:16 +0000 (22:12 +0300)]
Fix cors tests
Robert Newson [Wed, 19 Aug 2015 15:41:06 +0000 (16:41 +0100)]
Don't pass CSRF cookie to replicator
COUCHDB-2781
Robert Newson [Tue, 18 Aug 2015 09:50:29 +0000 (10:50 +0100)]
Whitelist CSRF header for CORS
x-couchdb-csrf is a permitted request header
x-couchdb-csrf-valid is a permitted response header
COUCHDB-2762
Robert Newson [Sun, 16 Aug 2015 12:06:01 +0000 (13:06 +0100)]
Whitelist CSRF header for CORS
COUCHDB-2762
ILYA Khlopotov [Thu, 13 Aug 2015 15:33:33 +0000 (08:33 -0700)]
Support endpoint overriding
There are two kinds of overrides:
- overriding regular endpoint
- overriding default handler (such as chttpd_db:handle_request/1)
Therefore there are two distinct options for overriding.
url_handler(<<"_all_dbs">>) ->
{override, fun mymodule:handle_all_dbs_req/1};
url_handler(_) ->
{default, fun mymodule:handle_request/1};
ILYA Khlopotov [Fri, 31 Jul 2015 18:35:24 +0000 (11:35 -0700)]
Return `{error, {illegal_database_name, Name}}`
ILYA Khlopotov [Fri, 31 Jul 2015 13:27:20 +0000 (06:27 -0700)]
Use `#httpd.qs` field
ILYA Khlopotov [Wed, 29 Jul 2015 18:59:42 +0000 (11:59 -0700)]
Use private to_lower instead of string:to_lower
ILYA Khlopotov [Wed, 29 Jul 2015 18:31:28 +0000 (11:31 -0700)]
Add chttpd_plugin hooks
We add following hooks:
- chttpd_plugin:before_request/1
- chttpd_plugin:after_request/2
- chttpd_plugin:handle_error/1
ILYA Khlopotov [Mon, 29 Jun 2015 13:19:11 +0000 (06:19 -0700)]
Use `#httpd.cors_config`
ILYA Khlopotov [Mon, 22 Jun 2015 18:37:54 +0000 (11:37 -0700)]
Use #httpd.absolute_uri
ILYA Khlopotov [Mon, 22 Jun 2015 12:32:39 +0000 (05:32 -0700)]
Refactor handle_request/1 to use #httpd_resp{}
Pass more info into #httpd{} and introduce #httpd_resp{} so we can
abstract updating stats and logging of request into separate functions.
We also prepare for introduction of before_request/after_request hooks.
ILYA Khlopotov [Wed, 29 Jul 2015 17:15:50 +0000 (10:15 -0700)]
Add `chttpd_auth:authorize/2` hook
ILYA Khlopotov [Fri, 19 Jun 2015 21:12:33 +0000 (14:12 -0700)]
Derive HandlerKey from path_parts
This is a preparation for introducing `before_request` hook.
Plugin might want to manipulate Path in order to affect handler selection.
Therefore HandlerKey calculation has to happen after
`chttpd_plugin:before_request` and it should be based on the value
returned from that call.
HandlerKey was constructed using `mochiweb_util:partition(Path, "/")`.
We change the logic to use first part of path_parts field of #httpd{}
record.
ILYA Khlopotov [Wed, 5 Aug 2015 21:31:31 +0000 (14:31 -0700)]
Use '?ADMIN_USER' for admin party
ILYA Khlopotov [Wed, 29 Jul 2015 16:40:23 +0000 (09:40 -0700)]
Introduce `chttpd_auth:authenticate` hook
Robert Newson [Wed, 5 Aug 2015 13:27:38 +0000 (14:27 +0100)]
Merge remote-tracking branch 'cloudant/2762-csrf'
Robert Newson [Tue, 4 Aug 2015 14:40:27 +0000 (15:40 +0100)]
Don't send empty buffer as it terminates response prematurely
Robert Newson [Fri, 31 Jul 2015 15:29:08 +0000 (16:29 +0100)]
Call CouchDB's CSRF validation
COUCHDB-2762
Ólafur Arason [Wed, 29 Jul 2015 18:24:56 +0000 (18:24 +0000)]
Fix vhost rewrite loop but
Robert Newson [Wed, 29 Jul 2015 17:17:27 +0000 (18:17 +0100)]
Port max_rewrites to chttpd
This commit incorporates the original work by Ronny Pfannschmidt
<Ronny.Pfannschmidt@gmx.de> and myself for COUCHDB-1441 and COUCHDB-1651.
Robert Newson [Wed, 29 Jul 2015 15:20:20 +0000 (16:20 +0100)]
Merge remote-tracking branch 'cloudant/chttpd-qs'
Robert Newson [Mon, 27 Jul 2015 12:11:29 +0000 (13:11 +0100)]
Handle waiting_for_updates in callback
COUCHDB-2724
Robert Newson [Mon, 27 Jul 2015 11:32:35 +0000 (12:32 +0100)]
Revert "Discard request body after request"
This reverts commit
56cf6412ad3572b5d07a281c5a25ec511af0530c.
ILYA Khlopotov [Thu, 23 Jul 2015 20:15:44 +0000 (13:15 -0700)]
Use `chttpd:qs*` instead of `couch_httpd:qs*`
Adam Kocoloski [Wed, 22 Jul 2015 21:02:31 +0000 (17:02 -0400)]
Merge branch '2724-chunked-buffering'
Adam Kocoloski [Wed, 22 Jul 2015 18:14:48 +0000 (14:14 -0400)]
Match old behavior when buffering is disabled
If the threshold is set to zero we make sure to send a separate chunk to
close the JSON, otherwise we just merge it into the previous chunk.
Adam Kocoloski [Wed, 22 Jul 2015 18:10:43 +0000 (14:10 -0400)]
Remove support for CouchDB =< 1.0.0
Thise UA-sniffing code has been in place to ensure interop with clients
running CouchDB versions older than 1.0.1. We should be safe to remove
it now.
Adam Kocoloski [Tue, 21 Jul 2015 13:57:24 +0000 (09:57 -0400)]
Define an accessor for the chunk buffer config val
Adam Kocoloski [Mon, 20 Jul 2015 21:16:10 +0000 (17:16 -0400)]
Allow configurable buffer size for all_docs, views
Now that couch_mrview can buffer chunked responses we should pass the
config value for the buffer size to it.
Adam Kocoloski [Wed, 24 Jun 2015 17:56:18 +0000 (13:56 -0400)]
Execute a callback for every complete DB traversal
This ensures that we don't enter a receive statement waiting for new DB
updates without first flushing the buffer.
COUCHDB-2724
Adam Kocoloski [Wed, 24 Jun 2015 17:47:01 +0000 (13:47 -0400)]
Add basic buffering support for other feed types
With this code it is possible that changes are buffered for a long
period of time and not sent out. Will work on addressing that next.
COUCHDB-2724
Adam Kocoloski [Tue, 23 Jun 2015 01:45:26 +0000 (21:45 -0400)]
Buffer rows for normal/longpoll feeds
This patch causes the coordinator to accumulate data in its own buffer
and reduce the number of calls to write data on the socket. The size of
the buffer is configurable:
[httpd]
chunked_response_buffer = 1490
The default is chosen to approximately fill a standard Ethernet frame.
COUCHDB-2724
Russell Branca [Tue, 21 Jul 2015 20:51:01 +0000 (20:51 +0000)]
Merge branch 'add-manual-migration-logic'
Russell Branca [Fri, 26 Jun 2015 22:30:23 +0000 (22:30 +0000)]
Don't allow security updates during cassim migration
Robert Newson [Tue, 21 Jul 2015 12:33:00 +0000 (13:33 +0100)]
Merge remote-tracking branch 'cloudant/dynamic-handlers'
ILYA Khlopotov [Wed, 15 Jul 2015 15:15:45 +0000 (08:15 -0700)]
Dynamic http endpoint handlers
Use `couch_epi` to implement dynamic http endpoint handlers.
The application which wishes to add dynamic endpoint would
have to do following:
1. Add a child into application supervisor
chttpd_handler:provider(myapp, myapp_httpd_handlers)
2. Provide `myapp_httpd_handlers` callback module
-module(myapp_httpd_handlers).
-export([url_handler/1, db_handler/1, design_handler/1]).
url_handler(<<"_foo">>) -> fun myapp_httpd:handle_foo_req/1;
url_handler(_) -> no_match.
db_handler(<<"_bar">>) -> fun myapp_httpd:handle_bar_req/2;
db_handler(_) -> no_match.
design_handler(_) -> no_match.
Robert Newson [Fri, 17 Jul 2015 17:15:31 +0000 (18:15 +0100)]
Validate host header
See enabling commit in couchdb-couch
COUCHDB-2752
ILYA Khlopotov [Thu, 16 Jul 2015 20:54:38 +0000 (13:54 -0700)]
Unify headers to be a list to avoid crashing CORS
ILYA Khlopotov [Mon, 29 Jun 2015 12:45:37 +0000 (05:45 -0700)]
Account for binary keys for headers in CORS
We do have headers' keys represented as either lists or binaries.
Make sure we don't crash on `string:to_lower`.
COUCHDB-2733
Adam Kocoloski [Mon, 22 Jun 2015 23:41:37 +0000 (19:41 -0400)]
Use a record for changes_callback accumulator
This change allows us to evolve the accumulator in a less-brittle way
and sets the stage for new data to be held in the accumulator to address
COUCHDB-2724.
In the course of this change I also switched the feed labels from strings
to atoms (they're only used for pattern matching in the accumulator, and
multiple matches are executed for every row in the feed, so it seemed
silly to be using Erlang lists for that comparison), and I explicitly
indicated when we start a chunked response instead of guessing it
heuristically based on other contents in the accumulator.
COUCHDB-2724
Adam Kocoloski [Mon, 22 Jun 2015 23:15:23 +0000 (19:15 -0400)]
Remove temporary upgrade clause
This clause was only needed for a very old hot code upgrade.
Paul J. Davis [Mon, 3 Nov 2014 22:15:29 +0000 (16:15 -0600)]
Increase nonce size by a byte
Robert Newson [Mon, 1 Jun 2015 14:12:21 +0000 (15:12 +0100)]
Discard request body after request
If a client sends a request body for a request that fails because the
database does not exist, they receive a 404 response but the request
body is not read. This prevents the next request on the same socket
being handled correctly.
Ensure the request body is consumed for every request.
Alexander Shorin [Thu, 18 Jun 2015 17:26:41 +0000 (20:26 +0300)]
Be more precisely on HTTP 404/405 responses for /_nodes/$node/*
Alexander Shorin [Thu, 18 Jun 2015 16:40:04 +0000 (19:40 +0300)]
Fix comments for /_node/$node handlers
Robert Newson [Thu, 18 Jun 2015 15:56:32 +0000 (16:56 +0100)]
Move node-specific endpoints under /_node/$name
Robert Newson [Wed, 17 Jun 2015 13:41:50 +0000 (14:41 +0100)]
Add _node_config, an endpoint to configure specific nodes from any node
Robert Newson [Wed, 17 Jun 2015 11:32:16 +0000 (12:32 +0100)]
Revert "Remove _config route on cluster"
This reverts commit
2a583cb0dfcd446ae259b272acd58068079c9b52.
Robert Newson [Wed, 17 Jun 2015 10:31:50 +0000 (11:31 +0100)]
Support virtual hosts
Russell Branca [Thu, 6 Nov 2014 22:48:51 +0000 (14:48 -0800)]
Disable couch_httpd_cors when chttpd_cors is active
Russell Branca [Wed, 5 Nov 2014 00:07:38 +0000 (16:07 -0800)]
CORS implementation for chttpd
Robert Kowalski [Sun, 1 Mar 2015 14:42:24 +0000 (15:42 +0100)]
add _changes?feed=live sugar for continuous
allow `feed=live` as sugar for `continuous` which is hard to type.
PouchDB already supports `live`.
PRs for the change:
https://github.com/apache/couchdb/pull/307
https://github.com/apache/couchdb-couch/pull/40
https://github.com/apache/couchdb-chttpd/pull/28
closes COUCHDB-2237
Alexander Shorin [Thu, 23 Apr 2015 20:50:54 +0000 (23:50 +0300)]
Fix chttpd tests using new test_util:start_applications protocol
Alexander Shorin [Thu, 23 Apr 2015 20:37:52 +0000 (23:37 +0300)]
Merge remote-tracking branch 'iilyak/2656-use-chttpd-functions'
This closes #31
COUCHDB-2656
Robert Newson [Fri, 3 Oct 2014 14:23:54 +0000 (15:23 +0100)]
Tolerate empty candidate list
Robert Newson [Sun, 19 Apr 2015 09:41:14 +0000 (10:41 +0100)]
Use attachment checksum as Etag if possible
Fixes COUCHDB-2668
Originally fixed in COUCHDB-1337
ILYA Khlopotov [Thu, 16 Apr 2015 14:50:58 +0000 (07:50 -0700)]
json_req_obj compartible with backdoor interface
Clustered call would return additional fields:
- requested_path
- raw_path
- secObj
COUCHDB-2656
Alexander Shorin [Mon, 13 Apr 2015 20:03:48 +0000 (23:03 +0300)]
Remove /_sleep endpoint
ILYA Khlopotov [Tue, 7 Apr 2015 15:49:53 +0000 (08:49 -0700)]
Export etag_match/2
COUCHDB-2656
Robert Kowalski [Fri, 13 Mar 2015 02:45:09 +0000 (03:45 +0100)]
add license file
Alexander Shorin [Thu, 26 Feb 2015 20:23:38 +0000 (23:23 +0300)]
Merge remote-tracking branch 'kxepal/rename-system-databases'
This closes #27
Alexander Shorin [Thu, 26 Feb 2015 18:55:25 +0000 (21:55 +0300)]
Rename "shard_db" option to "shards_db"
COUCHDB-2628
Alexander Shorin [Wed, 25 Feb 2015 21:39:45 +0000 (00:39 +0300)]
Add underscore prefix for dbs database name
That's how we name system databases and there should be no exceptions.
COUCHDB-2619
Robert Kowalski [Thu, 19 Feb 2015 20:21:25 +0000 (21:21 +0100)]
Remove _config route on cluster
In order to avoid users shooting themselves in the foot by using
`/_config/` on a clustered CouchDB with a loadbalancer in front,
we remove it on `15984` - it will be available for single-node-
mode on the backdoor port (`15986`) or for users that are feeling
lucky which want to fire curl requests to every node.
It also allows Fauxton to detect if it is running on a the backdoor
port. Fauxton will - if it gets a 200 instead of a 404 - show the
config-section to the user.
COUCHDB-2601 COUCHDB-2390 COUCHDB-2343
Jan Lehnardt [Sun, 8 Feb 2015 13:26:16 +0000 (14:26 +0100)]
add mango URL endpoints
Robert Kowalski [Wed, 19 Nov 2014 01:11:25 +0000 (02:11 +0100)]
Return ok:true on _bulk_doc update
Return `ok: true` on a successful _bulk_doc update like in
CouchDB 1.6.
Example success message on 2.0 (broken):
```
[{"id":"Brocket","rev":"6-
b6fa9e703c3eb92aa9c3a49cedf1e8c2"}]
```
Example error message on 2.0:
```
[{"id":"Blaggie-System","error":"conflict",
"reason":"Document update conflict."}]
```
Example success message on 1.x:
```
[{"id":"Brocket", "ok": true, "rev":"6-
b6fa9e703c3eb92aa9c3a49cedf1e8c2"}]
```
Finally closes COUCHDB-2462
Alexander Shorin [Thu, 5 Feb 2015 11:17:52 +0000 (14:17 +0300)]
Fix typo in config listener module name
Alexander Shorin [Wed, 4 Feb 2015 15:43:16 +0000 (18:43 +0300)]
Merge remote-tracking branch 'iilyak/2561-make-config-API-consistent'
This closes #21
COUCHDB-2561
ILYA Khlopotov [Fri, 30 Jan 2015 19:06:12 +0000 (11:06 -0800)]
Don't restart event handler on termination
COUCHDB-2561
ILYA Khlopotov [Thu, 29 Jan 2015 21:34:31 +0000 (13:34 -0800)]
config:get/3 is more strict now
The config:get/3 supports only following types for default argument
- atom `undefined`
- string (list)
- boolean
- float
- integer
COUCDB-2561
ILYA Khlopotov [Thu, 29 Jan 2015 21:33:57 +0000 (13:33 -0800)]
Update config_listener behaviuor
COUCHDB-2561
Will Holley [Mon, 2 Feb 2015 20:56:29 +0000 (20:56 +0000)]
Parse attachment-related parameters for /_changes
Match the way that couch_httpd_db:parse_changes_query handles attachment
related query parameters.
This closes #23
COUCHDB-2522
Signed-off-by: Alexander Shorin <kxepal@apache.org>
Will Holley [Sat, 31 Jan 2015 10:46:30 +0000 (10:46 +0000)]
Enable POST requests to /_changes in clustered CouchDB
Appropriate handling of a POST to _changes is already in place in
single node CouchDB. In clustered CouchDB, allow POST requests to pass
through to the underlying handler and existing logic will do the rest.
This closes #22
COUCHDB-2530
Signed-off-by: Alexander Shorin <kxepal@apache.org>
Alexander Shorin [Fri, 30 Jan 2015 07:39:23 +0000 (10:39 +0300)]
Merge remote-tracking branch 'iilyak/1145-_local_docs-handler'
Conflicts:
src/chttpd_db.erl
This closes #16
COUCHDB-1145
Will Holley [Thu, 29 Jan 2015 17:59:39 +0000 (17:59 +0000)]
Set view type before validating _all_docs parameters.
Matching couch_mrview, set view_type to "map" before validating query
parameters for _all_docs. This fixes a bug whereby validation fails
when specifying _all_docs?conflicts=true.
This closes #20
COUCHDB-2523
Signed-off-by: Alexander Shorin <kxepal@apache.org>
Will Holley [Thu, 29 Jan 2015 10:19:34 +0000 (10:19 +0000)]
validate _all_docs query parameters
Perform the same query parameter validation in the clustered interface
for /_all_docs requests as we do in the non-clustered interface.
This closes 19
COUCHDB-2523
Signed-off-by: Alexander Shorin <kxepal@apache.org>
Jan Lehnardt [Fri, 31 Oct 2014 14:53:10 +0000 (15:53 +0100)]
add setup
Alexander Shorin [Mon, 26 Jan 2015 04:07:43 +0000 (07:07 +0300)]
Use ADMIN_CTX macro from couch_db.hrl
Mike Wallace [Thu, 15 Jan 2015 15:31:09 +0000 (15:31 +0000)]
Convert {timeout, Error} errors to timeout
If chttpd got a {timeout, Error} error then it would return
that tuple to the client. Since Error is some internal specifics
this isn't particularly useful information to return to the client.
This commit converts it to our usual timeout response.
This closes #18
COUCHDB-2425
Signed-off-by: Alexander Shorin <kxepal@apache.org>
Alexander Shorin [Wed, 21 Jan 2015 01:40:05 +0000 (04:40 +0300)]
Merge remote-tracking branch 'kxepal/2538-revert-500-error-reason-changes'
This closes #17
Alexander Shorin [Fri, 9 Jan 2015 15:32:28 +0000 (18:32 +0300)]
Restore <<"unknown_error">> for HTTP 500 errors
This reverts changes made in
059229777 commit allowing chttpd to send
HTTP 500 errors in the same format as httpd does, e.g.:
{"error": "unknown_error", "reason": "function_clause", "ref": 100500}
COUCHDB-2538
Alexander Shorin [Wed, 21 Jan 2015 01:34:31 +0000 (04:34 +0300)]
Add tests for chttpd:error_info/1
ILYA Khlopotov [Fri, 19 Dec 2014 16:48:05 +0000 (08:48 -0800)]
Rename argument to reflect new semantic
ILYA Khlopotov [Fri, 19 Dec 2014 16:15:37 +0000 (08:15 -0800)]
Reuse _all_docs handler for _local_docs/_design_docs
ILYA Khlopotov [Thu, 18 Dec 2014 21:20:51 +0000 (13:20 -0800)]
Add _local_docs and _design_docs handlers
COUCHDB-1145
Paul J. Davis [Tue, 16 Dec 2014 20:57:06 +0000 (14:57 -0600)]
Merge branch '2517-open_revs=all-function_clause'
Fixes #15
ILYA Khlopotov [Mon, 8 Dec 2014 15:46:46 +0000 (07:46 -0800)]
Re-indent to reflect recent addtion of a case branch
COUCHDB-2517
ILYA Khlopotov [Mon, 8 Dec 2014 15:45:00 +0000 (07:45 -0800)]
Return error when open_revs=all and document doesn't exist
COUCHDB-2517
Paul J. Davis [Fri, 12 Dec 2014 20:33:34 +0000 (14:33 -0600)]
Merge branch '2491-refactor-couch-httpd-auth'
Fixes #13
Paul J. Davis [Thu, 4 Dec 2014 19:13:42 +0000 (13:13 -0600)]
Update chttpd_auth_cache for new couch_auth_cache
This updates the interface to chttpd_auth_cache to match the new
callback API expected by couch_httpd_auth. Specifically this allows for
the upgraded user documents to be written back to the correct user
database.
COUCHDB-2491
Robert Kowalski [Sat, 25 Oct 2014 02:45:07 +0000 (04:45 +0200)]
Fix location-header for documents with newlines in the name
Properly urlencode the Document-Id in the Location-field of the
header
Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>
COUCHDB-708
Robert Newson [Thu, 9 Oct 2014 18:48:07 +0000 (19:48 +0100)]
fix filtered replication
Alexander Shorin [Wed, 24 Sep 2014 20:51:21 +0000 (00:51 +0400)]
Rebrand X-Cloudant-Stack-Hash header for CouchDB
Alexander Shorin [Wed, 24 Sep 2014 15:38:38 +0000 (19:38 +0400)]
Use couch_log instead of ?LOG_*
Russell Branca [Wed, 10 Sep 2014 22:20:40 +0000 (15:20 -0700)]
Add CORS headers to chttpd_external:send_external_response
COUCHDB-2328