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