Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of Accept-Encoding header #248

Open
talset opened this issue Apr 27, 2022 · 1 comment
Open

Support of Accept-Encoding header #248

talset opened this issue Apr 27, 2022 · 1 comment

Comments

@talset
Copy link

talset commented Apr 27, 2022

For a few days we receive 403 on URL such https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

curl -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0' https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token -I
HTTP/2 403

To fix the issue, we need to provide Accept-Encoding to blc

curl -H 'Accept-Encoding: gzip, deflate, br' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0' https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token -I
HTTP/2 200

Describe the solution you'd like
Ideal it would be nice to be able to provide custom headers

Describe alternatives you've considered
Adding a flag such as --user-agent to provider --accept-encoding too

Additional context

@cnunciato
Copy link

It’s a bit of a hack — actually it’s a pretty big one 😂 — but if you find yourself in need a workaround, as we did, you can patch the underlying library:

const bhttp = require("bhttp");
const oldRequest = bhttp.request;
bhttp.request = function() {
    const [ url, options, callback ] = arguments;

    // Modify request options.
    // https://git.cryto.net/joepie91/node-bhttp/src/branch/master/lib/bhttp.js#L886
    options.headers.accept = "*/*";

    return oldRequest.apply(this, arguments);
};

https://github.com/pulumi/docs/blob/master/scripts/link-checker/check-links.js#L53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants