digitalbazaar / digitalbazaar/http-client

Add support for `content-encoding` and compressed `response.body`

Open
#30 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
2
Forks
8
PR merge metrics
No merged PRs in 30d

Description

This library fails if a route returns the following headers:

'content-type' => 'application/json; charset=utf-8 and
'content-encoding' => 'gzip',

In this case the response.body is gzipped json.
We need to support compressed response.bodies.

Note: Axios has an existing decompress function that appears to use zlib to automatically inflate compressed response.bodies.

Axios code here:

https://github.com/axios/axios/blob/738fa63661a7a5d7e8bf604436bb3b91648e327b/lib/adapters/http.js#L376-L401

EDIT: content-encoding is part of the fetch spec so it appears that something is broken in node 18.8-18.9 that is causing this issue somewhere down the line. Close this issue when content-encoding is working again.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the HTTP response handling and reproduce the case described with content-type application/json, content-encoding gzip, and a gzipped response.body. Compare the behavior with Axios's zlib-based decompression path across the noted Node 18.8-18.9 versions; done means compressed response bodies work, or the issue is confirmed to be an external Node regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.