szmarczak / http2-wrapper

Use HTTP/2 the same way like HTTP/1
MIT License
239 stars 18 forks source link

Support HTTPS servers without HTTP/2 support in auto.js #102

Open tgambet opened 9 months ago

tgambet commented 9 months ago

While running some requests through got using http2-wrapper I stumbled upon the following error when requesting websites that support SSL but do not seem to support HTTP/2. Edit: I believe it might be related to redirects.

Protocol "https:" not supported. Expected "http:"

The culprit seems to be this line:

https://github.com/szmarczak/http2-wrapper/blob/f1a1776d4b1aef1cd47d55b1a950986e86145a09/source/auto.js#L220

Changing it to

return delayAsyncDestroy((isHttps ? https : http).request(options, callback)); 

fixed the issue for me.

Have someone else been affected by this error ? Is it the correct fix ?