swlib / saber

⚔️ Saber, PHP异步协程HTTP客户端 | PHP Coroutine HTTP client - Swoole Humanization Library
https://packagist.org/packages/swlib/saber
Apache License 2.0
976 stars 124 forks source link

redirect后cookies失效 #131

Open blesswarrior opened 3 years ago

blesswarrior commented 3 years ago

正确响应的情况

$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://fees.uspto.gov/mntfee-services/v1/maintenancefee/details?patentNumber=8690232&applicationNumber=13869358');
curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd() . "/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd() . "/cookies.txt");
$result = curl_exec($ch);
dump($result);

未能正确响应

$response = SaberGM::get('https://fees.uspto.gov/mntfee-services/v1/maintenancefee/details?patentNumber=8690232&applicationNumber=13869358');
dump($response->getStatusCode());
dump($response->getBody()->getContents());

经过2次跳转后,正常结果应该是json文本。