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 7FC07EC16 for ; Mon, 25 Feb 2013 16:21:34 +0000 (UTC) Received: (qmail 76661 invoked by uid 500); 25 Feb 2013 16:21:33 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 76453 invoked by uid 500); 25 Feb 2013 16:21:27 -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 76390 invoked by uid 99); 25 Feb 2013 16:21:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 16:21:25 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kevin.r.coombes@gmail.com designates 209.85.214.169 as permitted sender) Received: from [209.85.214.169] (HELO mail-ob0-f169.google.com) (209.85.214.169) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 16:21:18 +0000 Received: by mail-ob0-f169.google.com with SMTP id ta14so3081826obb.0 for ; Mon, 25 Feb 2013 08:20:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:organization:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=PvKWd2IaZcPNThf/WBxQoupt++VCgOZfvEWoFMlek7A=; b=Tu9jf+PEls5awY/8zI9qm5cALL6mBbmmwef62oPMKhLOeK9UwzthYKLzkaGU4eu05A SAz/s5Saz2zQ8GfPCLkzmSknarhCmR5gfSN5q/zCtv2k8Jxaynch+832wJMLeHG62LDn x5pBRvlLJ8EVkCgjvmby36X8aojReOUX9exxxRYmKiT7u7d6yU8KPCtHYT13bknhfweK PATr/9kEqDP3Yfd62TgGFoM2aLZpqDOHnaj2lCZgDayiH0enfVMBFPNPaeWUD9HRH5JS bAndbGv3f1PRbktbA+o0UtmgxcFW0jiOOg/KzWF85xGnc0Wz3N/shx0pNggl5UWr8LAi iPYA== X-Received: by 10.182.0.111 with SMTP id 15mr8173989obd.27.1361809257713; Mon, 25 Feb 2013 08:20:57 -0800 (PST) Received: from [10.105.35.136] ([143.111.22.51]) by mx.google.com with ESMTPS id ri1sm14031544obc.12.2013.02.25.08.20.56 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Feb 2013 08:20:56 -0800 (PST) Message-ID: <512B8F67.9040006@gmail.com> Date: Mon, 25 Feb 2013 10:20:55 -0600 From: "Kevin R. Coombes" Organization: UT M.D. Anderson Cancer Center User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120312 Thunderbird/11.0 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: list functions, error checking, and content-type References: <5127A710.6020709@gmail.com> <5127BCD2.1070009@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Ryan, I think that is the same reference that Robert Newson supplied, and the JIRA page notes the "fix version" as 1.4 -- which is why I asked if there was some timeline for the release of 1.4. It would certainly be nice if the fix could be included in 1.3.... Thanks, Kevin On 2/22/2013 12:50 PM, Ryan Ramage wrote: > Kevin, I believe this was fixed as a part of : > https://issues.apache.org/jira/browse/COUCHDB-430 > > and I think may come out in a soon 1.3 release. > > > On Fri, Feb 22, 2013 at 11:45 AM, Kevin R. Coombes< > kevin.r.coombes@gmail.com> wrote: > >> Thanks; yes, it sounds exactly like that issue. >> >> If I read the "JIRA issues" page correctly, this problem is fixed as of >> version 1.4. Since the current stable release is 1.2.1, is there some >> (broad and clearly not binding...) estimate of when 1.4 might be available >> and usable by mere mortals? >> >> >> On 2/22/2013 11:17 AM, Robert Newson wrote: >> >>> Sounds like https://issues.apache.org/**jira/browse/COUCHDB-430 >>> . >>> >>> On 22 February 2013 17:12, Kevin R. Coombes> >>> wrote: >>> >>>> Hi, >>>> >>>> I am currently using CouchDB 1.2.0 on a Windows 7 machine. I have a >>>> database >>>> with several different view functions, and I am trying to define a list >>>> function that only makes sense when combined with _some_ of the views. >>>> Under >>>> the (not unrealistic) assumption that anything that a user *can* do, >>>> sooner >>>> or later, someone *will* do, I'd like the list function to check that the >>>> view it is being called with actually makes sense. If not, then I want >>>> to >>>> use the HTTP response to send an error message, with a proper error code. >>>> >>>> My first (failed) attempt looked something like this: >>>> >>>> function(header, request) { >>>> var row = getRow(); >>>> if (row.hasRequiredField) { >>>> start({"headers": "Content-Type": "text/html"}); >>>> // do what you need to do to 'send' this and all other rows >>>> } else { >>>> start({"code" 400, "headers": {"Content-Type": "text/html"}}); >>>> send("Helpful error message explaining the problem."); >>>> } >>>> >>>> This fails because the first call to "getRow" starts writing the HTTP >>>> response and sets the Content-Type to "application/json". Thus the later >>>> "start" calls fail to set the Content-Type or the response code. >>>> >>>> The only alternative I can think of at this point is to peek into the >>>> "request" argument to see if I can tell if the request is valid. But I >>>> think the only information I can get that might be relevant is the name >>>> of >>>> the view (by parsing the path element), and that causes difficulties with >>>> maintaining the application over time. I must either maintain a "white >>>> list" of known acceptable views or a "black list" of known unacceptable >>>> views. (And, applying the user principle above to the >>>> developer/maintainer, >>>> I know that I will forget to update this list at some point in time.) >>>> >>>> I found a StackOverflow question about this issue from September 2011 >>>> (http://stackoverflow.com/**questions/7595662/couchdb-** >>>> list-api-cant-seem-to-return-**plain-text >>>> ), >>>> but since the issue still exists, I assume that change either never got >>>> requested in JIRA or never got implemented. >>>> >>>> Is there some other way to accomplish what I want? Or do I have to give >>>> up >>>> on sending proper error codes and just set the Content-Type globally >>>> before >>>> calling getRow? Or should I put the issue into JIRA and hope someone >>>> fixes >>>> it? >>>> >>>> Thanks, >>>> Kevin >>>>