Gsoc: Add getRevisionDifference method with test, add header support to SocketClient and StreamClient, add POST support to getChanges method, add methods to BulkUpdater with tests. #42
Conversation
05f2c9f
to
48c80ed
Compare
… and update tests for it.
…reamClient. Correct the spelling errors in the code comments of the StreamClient and the SocketClient.
… the request headers in execute() method.
…BClientForBulkTest() methods to the CouchDBFunctionalTestCase. Add getBulkTestDatabase() method to the TestUtil.
* @return Response | ||
* @throws HTTPException | ||
*/ | ||
public function request( $method, $path, $data = null, $raw = false ) | ||
public function request( $method, $path, $data = null, $raw = false, array $headers = array()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this change also needed in AbstractHttpClient class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi beberlei..!
You meant in the request method of the Client interface..? It's not needed. It will be a desired addition though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please add it, you cannot extend an interface this way, it is not proper :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added it. Please let me know if there is any other issue. :)
…ace and update phpdoc. Correct inline comment in CouchDBClientTest.
Gsoc: Add getRevisionDifference method with test, add header support to SocketClient and StreamClient, add POST support to getChanges method, add methods to BulkUpdater with tests.
Hi..! I am working on a project under Google's summer of code program for Drupal which involves writing a php based replicator. I am following this link for implementing the replication protocol and this is the first set of changes that i have made.
I will try to describe most of the changes that have been done in the client. Let's go file by file.
getChanges()
method, whenever doc_ids parameter is set and is not null, POST is used instead of GET for the request as the number of document ids can be large and using the POST is also the recommended way. See api/da ase/changes.getRevisionDifference()
method has been added to the CouchDBClient class which sends a _POST /{db}/revs_diff request.testGetRevisionDifference()
has been added as the test forgetRevisionDifference()
method.testGetChanges()
method.updateDocuments()
method has been added. It's like the existingupdateDocument()
method, but instead of a document it takes an array having documents as array or as JSON strings. It's more convenient to add multiple documents to the Updater.setNewEdits()
method has been added, which sets the new_edits option to true/false. This prevents the database from assigning them new revision IDs and is needed for the replicator. It is also one of the options that request JSON for _POST /{db}/bulk_docs api can have. So it will also be a good feature addition.setFullCommitHeader()
has been added and it sets the X-Couch-Full-Commit in the HTTP request header sent by theexecute()
method to true/false. It's needed for the replicator.execute()
method has been modified for supporting custom HTTP request headers. Currently only X-Couch-Full-Commit is being sent.This file has been added and contains the tests for BulkUpdater. This was not there initially and tests the new changes along with the pre-existing methods also. However there is no test for
setFullCommitHeader()
method.getBulkTestDatabase()
method has been added which returns the name of the database to be used for tests in BulkUpdaterTest. It's like the existinggetTestDatabase()
method.getBulkTestDatabase()
method has been added which returnsTestUtil::getBulkTestDatabase()
;createCouchDBClientForBulkTest()
method has been added and returns an instance of CouchDBClient to be used in the tests for BulkUpdater.request()
method takes the request headers also. This is needed as sometime we have to use the customer HTTP header like the above described X-Couch-Full-Commit, content type is not always application/json or the Accept header can be multipart/mixed. All this was not possible with the earlier clients and are needed for the requests of the replicator.