untitled notebook

node v14.20.1
version: master
endpointsharetweet
require('url').urlToHttpOptions = function urlToHttpOptions(url) { const options = { protocol: url.protocol, hostname: typeof url.hostname === 'string' && String.prototype.startsWith.call(url.hostname, '[') ? String.prototype.slice.call(url.hostname, 1, -1) : url.hostname, hash: url.hash, search: url.search, pathname: url.pathname, path: `${url.pathname || ''}${url.search || ''}`, href: url.href }; if (url.port !== '') { options.port = Number(url.port); } if (url.username || url.password) { options.auth = `${url.username}:${url.password}`; } return options; }; const got = require('got'); const http2wrapper = require('http2-wrapper'); const got2 = got.extend({ http2: true, request: http2wrapper.auto }); (async () => { const {headers} = await got2('https://httpbin.org/anything'); console.log(headers[':status']); })();
Loading…

no comments

    sign in to comment