Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF2D17421 for ; Sun, 18 Sep 2011 07:13:53 +0000 (UTC) Received: (qmail 1904 invoked by uid 500); 18 Sep 2011 07:13:52 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 1708 invoked by uid 500); 18 Sep 2011 07:13:47 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 1669 invoked by uid 99); 18 Sep 2011 07:13:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Sep 2011 07:13:46 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ambauen@gmail.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Sep 2011 07:13:39 +0000 Received: by bke5 with SMTP id 5so6304313bke.11 for ; Sun, 18 Sep 2011 00:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=qF98UQmENAu3A94QJvU9AWQfwLmxrQL1mvjSVBbeY1s=; b=E4biYU0MB4wMz1mq0JR+Vf2gz4OrlASqxaaLe7twpZ6eJzVsDuzeg7qMuu26KbXEu4 C0JxxpN3X9IcK1+vizgY03/6PWnE/+Zwyq+x/4jcUjapiSYAjZ69I8+4qVoi4sYuTGy/ Xa7eowkuOMxqXr0Yt43Hbb77cXRgN7KOU4Na4= MIME-Version: 1.0 Received: by 10.204.0.70 with SMTP id 6mr699474bka.258.1316329999252; Sun, 18 Sep 2011 00:13:19 -0700 (PDT) Sender: ambauen@gmail.com Received: by 10.205.81.138 with HTTP; Sun, 18 Sep 2011 00:13:19 -0700 (PDT) Date: Sun, 18 Sep 2011 00:13:19 -0700 X-Google-Sender-Auth: T0r94yJvbfyuC3Ebt5eZW8aOBoY Message-ID: Subject: Empty response for PUT in CouchDB 1.1.0 From: Dylan Ambauen To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=00151750de3c033e1f04ad31f676 X-Virus-Checked: Checked by ClamAV on apache.org --00151750de3c033e1f04ad31f676 Content-Type: text/plain; charset=ISO-8859-1 I'm getting an empty response body to a PUT request with CouchDB 1.1.0. This is unexpected behavior. Response headers are properly formatted. The response is 201 Created, which usually means the operation completed successfully. The PUT operation does complete, all of the data is written back to couchdb. The Etag header is appropriately updated to the next revision, and matches what is actually saved to couch. Content-length is set to 97, but the response itself is empty. Response body is blank. Now, for the inconsistent part. The empty response only occurs when the document being PUT gets big. The issue does not seem to correlate to number of updates to the doc, but rather size of the doc being updated. When I update a doc of size 1206 bytes (which is not that big!), I get an appropriate response. When I update a doc of 1310 bytes, I get an empty response. 1206 and 1310 specifically are sample values from my tests to isolate the problem. Those byte counts are included in the request headers as content length. It is the string length of the doc I am attempting to write. In my example below, the request content length is 1534, but i have shortened the content for brevity. Doubt that the data itself matters, but maybe 10 simple string fields of <100 bytes and a few fields containing arrays or hashes, with < 100 items, etc. Nothing fancy, Couch should be able to handle this. For example: REQUEST: PUT /testdb/36e04ac8eb90ca90269c1712510593f0 HTTP/1.0 Host: 192.168.0.116 Content-Length: 1534 Content-Type: application/json {"_id":"36e04ac8eb90ca90269c1712510593f0","_rev":"182-6046970607e6f9f39ee8d9f774c57fb4","foo":"bar...."} RESPONSE: HTTP/1.0 201 Created Server: CouchDB/1.1.0 (Erlang OTP/R13B03) Location: http://192.168.0.116/testdb/36e04ac8eb90ca90269c1712510593f0 Etag: "183-4006347f2e64ed9b4e5ce8c3f57e4dfc" Date: Sat, 17 Sep 2011 20:04:26 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 97 Cache-Control: must-revalidate (the body of the response is empty, this is the error condition. nothing.) Whereas, we would expect to see a response like: {"ok":true,"id":"36e04ac8eb90ca90269c1712510593f0","rev":"183-4006347f2e64ed9b4e5ce8c3f57e4dfc"} The only two links I've found so far are below, but both were solved by some javascript client settings. I'm not using a js client. First link is from this list, thanks. http://mail-archives.apache.org/mod_mbox/couchdb-user/201011.mbox/%3CAANLkTimSxUWQhwYfTTGe1vNkhkf2xnMiWmt9eriKMU8P@mail.gmail.com%3E http://stackoverflow.com/questions/2503911/getting-an-empty-response-when-calling-couchdb-over-ajax I'm connecting from PHP with a simple PHP Couch client, like: private function execute() { fwrite($this->sock, $this->getRequest()); $response = ''; while(!feof($this->sock)) { $response .= fgets($this->sock); } echo "
REQUEST: {$this->getRequest()}
RESPONSE: {$response}
"; //the debug statement outputting my example above $this->response = new CouchDBResponse($response); return $this->response; } I recently upgraded from CouchDB 0.8.0 to 1.1.0, my client did not have any problems with 0.8.0. It is a problem now because without a response body, the client thinks the PUT failed. Normally we would want to validate a PUT with some logic like: $res = CouchDB::q("/36e04ac8eb90ca90269c1712510593f0", 'PUT', json_encode($doc))->getBody(true); if (isset($res->ok) && ($res->ok == 1) && ($res->id == $doc->_id) ) { //ok } else { throw new Exception(...); } So the client thinks the update failed, when in fact it did not. Only that Couch failed to send back a properly formatted response. Client copy of the doc is now out of rev sync with the server, and the client dies. Additional updates to the client side doc are lost as later writebacks are rejected without the correct _rev. Suppose I could inspect the Etag header of the response, which appears to be accurate. However, also seems like a hack that shouldnt be necessary. Furthermore, I cant find any documentation that it is ok to rely upon an Etag header when the response body is empty. Thats the point of awaiting a response with ok=1, right? Also, I have set etc/couchdb/local.ini without luck. [couchdb] delayed_commits = false Thanks for any assistance or ideas. Cheers, Dylan --00151750de3c033e1f04ad31f676--