sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.3k stars 935 forks source link

Issues with HTTP/2 and cache enabled #1786

Open szmarczak opened 3 years ago

szmarczak commented 3 years ago
import got from 'got';

const cache = new Map();

await got.get('https://szmarczak.com/favicon.ico', {
    retry: {limit: 0},
    cache,
    http2: true
});

const {headers, body, isFromCache} = await got.get('https://szmarczak.com/favicon.ico', {
    retry: {limit: 0},
    cache,
    http2: true
});

console.log(headers, body.length, isFromCache);

Headers contain ::status instead of :status

szmarczak commented 3 years ago
import got from 'got';

const {headers, body} = await got.get('pet/findByStatus', {
    prefixUrl: 'https://petstore.swagger.io/v2',
    timeout: {request: 400},
    responseType: 'text',
    searchParams: { status: 'available' },
    retry: {limit: 0},
    cache: new Map(),
    http2: true,
    headers: {
        'x-trace-id': 'foo',
        'user-agent': 'foo-bar/baz, bash'
    }
});

console.log(body);

this should time out but it doesn't.