couchdb-nano icon indicating copy to clipboard operation
couchdb-nano copied to clipboard

db.head does not return content-length header

Open creativityjuice opened this issue 2 years ago • 1 comments

Trying to use db.head to get document size fast, it returns headers without content-length. I switched to axios just for that call to access document size.

Here is a simple piece of code :

const db = nano.db.use('accounts');
const nano_account_headers = await db.head('00000000-0000-0000-0000-ffffffffffff');
console.log('nano_account_headers -', nano_account_headers);
const axios_account = await axios.head(`${db_url}/accounts/00000000-0000-0000-0000-ffffffffffff`);
console.log('axios_account.headers -', axios_account.headers);

Expected Behavior

Here is what I get with axios, and therefor have with nano:

axios_account.headers - {
  server: 'nginx',
  date: 'Mon, 20 Jun 2022 13:24:14 GMT',
  'content-type': 'application/json',
  **'content-length': '1156',**
  connection: 'close',
  'cache-control': 'must-revalidate',
  etag: '"xx-xxxxxxxxxxxxxxxxxxxxxxxxx"',
  'x-couch-request-id': 'xxxxxxxxxx',
  'x-couchdb-body-time': '0',
  'strict-transport-security': 'max-age=31536000; includeSubdomains; preload'
}

Current Behavior

Here is what I get with nano:

nano_account_headers - {
  uri: 'https://xxxxxxxx.com/accounts/00000000-0000-0000-0000-ffffffffffff',
  statusCode: 200,
  date: 'Mon, 20 Jun 2022 13:24:14 GMT',
  'content-type': 'application/json',
  connection: 'close',
  'cache-control': 'must-revalidate',
  etag: '"xx-xxxxxxxxxxxxxxxxxxxx"',
  'x-couch-request-id': 'xxxxxxxxxx',
  'x-couchdb-body-time': '0',
  'strict-transport-security': 'max-age=31536000; includeSubdomains; preload'
}

Your Environment

  • Version used: 7.1.1
  • Browser Name and version: Node 16.5.1
  • Operating System and version (desktop or mobile): Ubuntu 20.04

creativityjuice avatar Jun 20 '22 13:06 creativityjuice

The content-length gets removed, maybe @glynnbird can help why?

big-r81 avatar Jun 20 '22 15:06 big-r81