开发者

How to check if a couchdb document exists (without retrieving it)?

开发者 https://www.devze.com 2022-12-30 01:20 出处:网络
How can I just check if a document exists, mabye get the revision, but not make couchdb send the body of the document?

How can I just check if a document exists, mabye get the revision, but not make couchdb send the body of the document?

I remember I saw this explained somewhere but I cannot find it.

Edit: Iirc in the ex开发者_如何学Goample you received only a http header with no data. The header indicated if present or not.

Edit2: Evan suggests to make a HEAD request (instead of GET). This answers my question.

CouchDB sends an ETag Header for document requests. The ETag Header is simply the document's revision in quotes.

Quoted from: http://wiki.apache.org/couchdb/HTTP_Document_API#ETags.2BAC8-Caching


Instead of performing a HTTP GET request, do a HTTP HEAD request. This will only return the headers and no content. The returned status will tell you if the object exists.

0

精彩评论

暂无评论...
验证码 换一张
取 消