Porting https://github.com/sindresorhus/got/pull/11