Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8CDD47152 for ; Wed, 20 Jul 2011 23:32:57 +0000 (UTC) Received: (qmail 10566 invoked by uid 500); 20 Jul 2011 23:32:57 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 10472 invoked by uid 500); 20 Jul 2011 23:32:56 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 10464 invoked by uid 99); 20 Jul 2011 23:32:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2011 23:32:56 +0000 X-ASF-Spam-Status: No, hits=1.8 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,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 randall.leeds@gmail.com designates 209.85.214.180 as permitted sender) Received: from [209.85.214.180] (HELO mail-iw0-f180.google.com) (209.85.214.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2011 23:32:49 +0000 Received: by iwn9 with SMTP id 9so1030720iwn.11 for ; Wed, 20 Jul 2011 16:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=L+q7eFttpWVq+Iyw14A3tDsf/hnXPzg4nH+YZRsLmuw=; b=FMO8jp7qc8yiSetj1YFd8ms2kl5JtRk0rPxzWqo2McL/bx2wz9JvZvL+SmlS+GTHTE hRZX5mBwpEzrL9ASgrEMLy8ID4xTxiuYvopPnamrLGcK6CD67Xd3bc6RbcLuKVdMAm/Z cmcqusLo6MIhD/FO0kZvW2uGTiIkgQcGXTek8= MIME-Version: 1.0 Received: by 10.231.112.88 with SMTP id v24mr8569509ibp.80.1311204747491; Wed, 20 Jul 2011 16:32:27 -0700 (PDT) Received: by 10.43.49.9 with HTTP; Wed, 20 Jul 2011 16:32:27 -0700 (PDT) In-Reply-To: References: Date: Wed, 20 Jul 2011 16:32:27 -0700 Message-ID: Subject: Re: Confused handling of HEAD requests From: Randall Leeds To: dev@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Wed, Jul 20, 2011 at 15:20, Paul Davis wrote: > On Wed, Jul 20, 2011 at 5:15 PM, Randall Leeds wrote: >> On Wed, Jul 20, 2011 at 15:09, Paul Davis wrote: >>> On Wed, Jul 20, 2011 at 5:03 PM, Travis Jensen wrote: >>>> couch_httpd.erl seems to be confused about what it wants to do with HEAD >>>> requests. >>>> >>>> On the one hand, it supports catching {http_head_abort, Resp} and will throw >>>> that in start_response/3 and start_response_length/4 if your method is set >>>> to HEAD. >>>> >>>> On the other hand, it sets all HEAD requests to GET, so no handler can ever >>>> know a HEAD request was made (instead, it lets Mochiweb strip the body). >>>> >>>> I can appreciate the simplicity of the latter, but >>>> the schizophrenic behavior seems odd. I've also got a custom handler that >>>> would really like to know if it is HEAD or GET (generating the body takes a >>>> lot of CPU, but I know its length because I store it in a document). >>>> >>>> First question: should Couch really set all HEAD requests to GET? >>>> (Personally, I think not) >>>> Second question: does anybody know how bad it would be to remove that HEAD >>>> -> GET mapping? >>>> >> >> It would be bad since a lot of the handlers specifically match against >> the method being GET. >> I have a ticket open to do smarter things with HEAD in general, >> especially as it relates to caching proxies and ETags: >> https://issues.apache.org/jira/browse/COUCHDB-941 >> >> It's something we should definitely set about fixing eventually, but I >> don't know what the priority is. >> >>>> Cheers. >>>> >>>> tj >>>> -- >>>> *Travis Jensen* >>>> *** >>>> *Read the Software Maven @ http://softwaremaven.innerbrane.com/ >>>> Read my LinkedIn profile @ http://www.linkedin.com/in/travisjensen >>>> Read my Twitter mumblings @ http://twitter.com/SoftwareMaven >>>> Send me email @ travis.jensen@gmail.com >>>> >>>> **What kind of guy calls himself the Software Maven???** >>>> >>> >>> I don't have the answer at the tip of my fingers, but IIRC there was a >>> specific interaction that we had to do that so that something else >>> didn't break. I wonder if its possible to tag the request with a >>> special "is actually a HEAD request" thing so users can check. >> >> I don't like an "is actually a HEAD request" flag. >> Adding HEAD handlers is the right approach, but if we want to be lazy >> we could support a fallback to GET when we get a function_clause error >> trying to call the handler. >> > > Yeah, its definitely a hack. A fallback on function_clause would > definitely be much cleaner I think. Only thing is I tend to wonder if > there'd be a performance hit since our entire HTTP stack currently > relies on HEAD -> GET, which would be generate a lot of exception > handling. It'd only occur when people do a HEAD request, so normal operation would be fine? Clearly we'd want to log a warning or something and start implementing all the HEAD responses properly. > >>> >>> I'd search through the dev@ list for chatter on that mapping around >>> the time it was made. I'm pretty sure there was a thread that we did >>> some discussion on that. >>> >> >