From couchdb-user-return-1580-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Tue Oct 21 16:35:40 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 78702 invoked from network); 21 Oct 2008 16:35:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Oct 2008 16:35:40 -0000 Received: (qmail 83504 invoked by uid 500); 21 Oct 2008 16:35:41 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 83478 invoked by uid 500); 21 Oct 2008 16:35:41 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 83467 invoked by uid 99); 21 Oct 2008 16:35:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Oct 2008 09:35:41 -0700 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=SPF_PASS,WHOIS_DMNBYPROXY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of benramsey.lists@gmail.com designates 74.125.92.146 as permitted sender) Received: from [74.125.92.146] (HELO qw-out-1920.google.com) (74.125.92.146) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Oct 2008 16:34:28 +0000 Received: by qw-out-1920.google.com with SMTP id 4so1111769qwk.54 for ; Tue, 21 Oct 2008 09:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=YzrpjePqFGtbl/k8kc/cvWhaJSvamoGYXUZ9fIGdA+g=; b=YC444OiIMJSyMeT0cPKB1iTo81sTbYuQKynyBO3FWxpBg32IKPUlDfmJ4EnmfRoMu/ yJR+FQNWSDc+d/Gb+phK/gjYQ/SxeQZLBNUibRCKGYQdx57ocNJmLXVM25tB4MrFx5KZ vriHR24BNlgr3ATEridQ+O3MYU8J+EzP5/1W0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=RTvvWgIpvhhpP5+ujfBuYgPpnrGodERuKQB+TddUuSdukula/CjNSpJ2rMgCjh0vwv TmBvzapeWwlEj5B4bK9TnE/Ov46ErZAX/tv9isEFLLEUzs82Kxq2lPyIBTX0esiB2q6L gDX7eSdQbGjKnbGUCil1iWcOQOC/h/qTVTp3o= Received: by 10.214.243.3 with SMTP id q3mr13419009qah.77.1224606820522; Tue, 21 Oct 2008 09:33:40 -0700 (PDT) Received: from bramsey-mb.local (wan-xl1.paetec.ny.schematic.com [74.8.31.5]) by mx.google.com with ESMTPS id 6sm4979271qwd.4.2008.10.21.09.33.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Oct 2008 09:33:40 -0700 (PDT) Message-ID: <48FE0440.9090806@gmail.com> Date: Tue, 21 Oct 2008 12:33:04 -0400 From: Ben Ramsey User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: couchdb-user@incubator.apache.org Subject: Re: 412 on update References: <48FD8C63.9010202@tangentlabs.co.uk> In-Reply-To: <48FD8C63.9010202@tangentlabs.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 10/21/08 4:01 AM, Jonathan Moss wrote: > Hi everyone, > > I am using the CouchDB PHP library (from > http://couchprojects.googlecode.com/svn/trunk/libraries/php/) to > communicate with the database an I am having some issues updating a > design document. When I try to save the design document I receive a 412 > HTTP status code. The code below is a simplification of what I am doing > but should explain what I am trying to do. > > $objCouch = new Couch(array("host" => localhost, "port" => 5984)); > $objDesignDoc = $objCouch->database($strDB)->get("_design/ADesignDoc"; > $objFunction = new stdClass(); > $objFunction->map = "function(doc){if(doc.Type = 'ANode'){emit(doc.Name, > doc);}}"; > $objDesignDoc->views->$strFunc = $objFunction; > $objDesignDoc->save(); > echo "Status: " . $objDesignDoc->lastStatusCode . "\n"; > > What does a 412 status code mean in this context and does anyone have > any idea what I can do to fix it? I'm not sure what a 412 means in this context, but I can tell you what a 412 *should* mean. :-) 412 is the HTTP status code for "Precondition Failed." From Section 10.4.13 of RFC 2616: "The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server. This response code allows the client to place preconditions on the current resource metainformation (header field data) and thus prevent the requested method from being applied to a resource other than the one intended." Thus, the point is that the client (your application connecting to Couch DB) can set one or more headers that the server can check. If any of them evaluate to false on the server, then the server would send a 412 Precondition Failed response to let you know that a precondition you set failed, so it can't return a response. I'm not sure if that's what Couch DB is doing in this case, but I hope this helps you narrow down the problem. -- Ben Ramsey http://benramsey.com/