Skip to content

Commit

Permalink
fix: disable compression
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Sep 22, 2022
1 parent c4fc8d4 commit 8fc0826
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 8 additions & 7 deletions index.js
Expand Up @@ -2,7 +2,12 @@

const pReflect = require('p-reflect')
const { URL } = require('url')
const got = require('got')

const got = require('got').extend({
decompress: false,
responseType: 'buffer',
retry: 0
})

const mergeResponse = (responseOrigin = {}, responseDestination = {}) => ({
statusMessage: 'Not Found',
Expand All @@ -12,12 +17,8 @@ const mergeResponse = (responseOrigin = {}, responseDestination = {}) => ({
...responseDestination
})

const reachableUrl = async (url, opts = {}) => {
const req = got(url, {
...opts,
retry: 0,
responseType: 'buffer'
})
const reachableUrl = async (url, opts) => {
const req = got(url, opts)

const redirectStatusCodes = []
const redirectUrls = []
Expand Down
9 changes: 9 additions & 0 deletions test/index.js
Expand Up @@ -160,3 +160,12 @@ test('fast unreachable request resolution', async t => {
t.is(res.statusCode, 404)
t.is(res.statusMessage.toLowerCase(), 'not found')
})

test('header `content-length` is present', async t => {
const url = 'https://cdn-microlink.vercel.app/file-examples/file_example_CSV_5000.csv'
const res = await reachableUrl(url)
t.is(res.url, url)
t.is(200, res.statusCode)
t.is(res.statusMessage, 'OK')
t.truthy(res.headers['content-length'])
})

0 comments on commit 8fc0826

Please sign in to comment.