apache / apache/couchdb-nano

db.head does not return content-length header

Open
#301 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
689
Forks
167
Avg merge
1h
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

Research direction

Start at the db.head('00000000-0000-0000-0000-ffffffffffff') call and compare its returned headers with the axios.head response shown in the issue. Done means db.head exposes the document's content-length header without requiring a separate axios request.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.