doctrine / couchdb-odm

A Document Mapper based on CouchDB
http://www.doctrine-project.org
MIT License
150 stars 53 forks source link

Database compaction does not send correct Content-Type header #74

Closed danielkbx closed 11 years ago

danielkbx commented 11 years ago

When calling compactDatabase on CouchDBClient the created request does not contain the needed header field Content-Type which causes an error from CouchDB.

Since there are no request to CouchDB which do not accept application/json as response this patch should easily fix it.

diff --git a/application/library/Doctrine/CouchDB/HTTP/SocketClient.php b/application/library/Doctrine/CouchDB/HTTP/SocketClient.php
index ee4402e..406c3a3 100644
--- a/application/library/Doctrine/CouchDB/HTTP/SocketClient.php
+++ b/application/library/Doctrine/CouchDB/HTTP/SocketClient.php
@@ -93,12 +93,13 @@ class SocketClient extends AbstractHTTPClient
     // available in the locale net.
     $request .= "Connection: " . ( $this->options['keep-alive'] ? 'Keep-Alive' : 'Close' ) . "\r\n";

+               $request .= "Content-type: application/json\r\n";
+
     // Also add headers and request body if data should be sent to the
     // server. Otherwise just add the closing mark for the header section
     // of the request.
     if ( $data !== null )
     {
-            $request .= "Content-type: application/json\r\n";
         $request .= "Content-Length: " . strlen( $data ) . "\r\n\r\n";
         $request .= "$data";
     }
beberlei commented 11 years ago

Fixed