Re: How to express no matching results in HTTP SEARH method?

Austin Wright <aaa@bzfx.net> Wed, 04 November 2020 20:52 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 3B0563A0E82 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 4 Nov 2020 12:52:40 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.748
X-Spam-Level:
X-Spam-Status: No, score=-2.748 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=bzfx.net
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LWc0Jbb4odVW for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 4 Nov 2020 12:52:38 -0800 (PST)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 779823A0DEF for <httpbisa-archive-bis2Juki@lists.ietf.org>; Wed, 4 Nov 2020 12:52:38 -0800 (PST)
Received: from lists by lyra.w3.org with local (Exim 4.92) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1kaPjK-0007H5-Cx for ietf-http-wg-dist@listhub.w3.org; Wed, 04 Nov 2020 20:50:06 +0000
Resent-Date: Wed, 04 Nov 2020 20:50:06 +0000
Resent-Message-Id: <E1kaPjK-0007H5-Cx@lyra.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by lyra.w3.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <aaa@bzfx.net>) id 1kaPjJ-0007GK-EZ for ietf-http-wg@listhub.w3.org; Wed, 04 Nov 2020 20:50:05 +0000
Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by titan.w3.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <aaa@bzfx.net>) id 1kaPjH-0000VE-R3 for ietf-http-wg@w3.org; Wed, 04 Nov 2020 20:50:05 +0000
Received: by mail-pg1-x52a.google.com with SMTP id g12so17578206pgm.8 for <ietf-http-wg@w3.org>; Wed, 04 Nov 2020 12:50:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bzfx.net; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=AvL0G15MEpGFSWbKGytK2rVNHSfRKQWGCWMDQzsTr5k=; b=vapZ/+8wVou/82oLRZvtcC2GWnJNECycdI2lIox4xELEb1ZR/dNQlk0hIqXiyrlABe QJegHsVk3JmOE/aknyEm/dcnuG6jGoZwE7aAHt4kf+KDAWjf+yL01W2WcmigH1WUcada B5Gg/aC2+Vxd4pMclI9AQ2tHVJJS8S/JzrHfA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=AvL0G15MEpGFSWbKGytK2rVNHSfRKQWGCWMDQzsTr5k=; b=th82wks4CWp/tIIXwQEbriTXqxRIq2N6WDkY1yeU2lydpd8ykc1TwZWj0/ALoK9YVJ mXqMasCNuBMuTvNnAbLm+usACWHAiwiK6bQPJV7YBEkv31UguOTMK6IkHaJjjacQvKYY qU8um5phwh890YQWQt1hzr/nNBnFW+eajcQLuy2vB5s0T8AW5LYJGTlJpnB7o90EWQaR 5jaqMuOG2u4fuCWF9gnijgPN28GylCSsfaL0AxOeV5jAAa5ioAasQmKwlgWrqqyFvAhs kbAxSk4PJL11RndEprN9SPc010yMq4bfDQPWEJHMQ52bSSEH6git9MvWYg5GSuGF30X+ 8FZQ==
X-Gm-Message-State: AOAM531Hg2h8qUzTovZ5bg4JgmJcwL8y8mOH76YjFzsA8WI+cCcEhJfq O5scIFxsmekRZ1kUsQjZoHEAWw==
X-Google-Smtp-Source: ABdhPJx+1rAhODnVjzjBymxFXJCTLyxJqu5c4K+IBWVkMrAzdX+02xgrMJBAR/FqsXXekZm6xpmBhw==
X-Received: by 2002:a17:90b:180f:: with SMTP id lw15mr5949854pjb.119.1604522992016; Wed, 04 Nov 2020 12:49:52 -0800 (PST)
Received: from [192.168.0.122] ([97.124.238.248]) by smtp.gmail.com with ESMTPSA id lk13sm2777997pjb.43.2020.11.04.12.49.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Nov 2020 12:49:50 -0800 (PST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\))
From: Austin Wright <aaa@bzfx.net>
In-Reply-To: <CALOnmf-e24a=9ScKg3M==cSpG8TMd1JnMiecWgUMtD0a17xRgA@mail.gmail.com>
Date: Wed, 04 Nov 2020 13:49:49 -0700
Cc: ietf-http-wg <ietf-http-wg@w3.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <DE3B489F-34C5-461C-A34E-142C0595498C@bzfx.net>
References: <CALOnmf-e24a=9ScKg3M==cSpG8TMd1JnMiecWgUMtD0a17xRgA@mail.gmail.com>
To: Sawood Alam <ibnesayeed@gmail.com>
X-Mailer: Apple Mail (2.3608.120.23.2.4)
Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=aaa@bzfx.net; helo=mail-pg1-x52a.google.com
X-W3C-Hub-Spam-Status: No, score=-6.1
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1kaPjH-0000VE-R3 3c2f4d11e576bbf65de87be6c7399afa
X-Original-To: ietf-http-wg@w3.org
Subject: Re: How to express no matching results in HTTP SEARH method?
Archived-At: <https://www.w3.org/mid/DE3B489F-34C5-461C-A34E-142C0595498C@bzfx.net>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/38160
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>


> On Nov 3, 2020, at 19:40, Sawood Alam <ibnesayeed@gmail.com> wrote:
> 
> Hi,
> 
> What would be an appropriate status code if the target resource of the SEARCH method wants to provide an entity to convey that the search operation yielded no results? In traditional GET-style searching, one could return a 404, would that still be an option (I doubt it as it would mean the target resource itself that performs the search is not found)?

A search result with zero results is still a resource that exists, so the status code should be 200. This is also true for `GET /search?q={query}`.

If the client expects at least one result, but none are returned, it doesn’t need a status code to figure out something’s up.

This is different from looking up a single resource by its URI. If an HTML form says to use `GET /item?id={id}` to look up a product, the response will be the actual product itself (not a query result), so either it exists at that URI (200), or it doesn’t (404).

It’s the difference between saying “Make me a list of all the books on the second shelf” (an empty list is still a list, 200) and “Get me the first book on the second shelf” (That’s an error if there’s no book there, 404).

> 
> The specification seems to suggest usage of 204, but in that case no content can be returned in the response, which may be desired in some cases. Also, 204 is a success response, which means a client might repeat the request, while a 4xx response would suggest that there is no point in repeating the request without making changes to it.

A 204 is identical to sending a 200 response with Content-Length: 0

If you want to suggest that the response is not going to change in the near future, use caching headers.

> 
> Best,
> 
> --
> Sawood Alam

Cheers,

Austin.