codemanki / cloudscraper

--DEPRECATED -- 🛑 🛑 Node.js library to bypass cloudflare's anti-ddos page
MIT License
600 stars 139 forks source link

Fix brotli compressed JSON responses #271

Closed ghost closed 4 years ago

ghost commented 4 years ago

Request doesn't decompress Brotli responses and calls JSON.parse before we have a chance to decompress it. The solution is to parse the response as JSON ourselves whenever the json option is truthy, following request's example to match the expected behavior.

I had to adjust lib/brotli.js since a test was modifying it's state and causing the new tests to fail.

TravisBuddy commented 4 years ago

Hey @pro-src,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 61d3e970-e211-11e9-a6b9-35e0da372496
codemanki commented 4 years ago

Thank you!