卷曲,跟随位置,但只获得新位置的标题? [英] Curl, follow location but only get header of the new location?

查看:101
本文介绍了卷曲,跟随位置,但只获得新位置的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道当我设置CURLOPT_FOLLOWLOCATION为true,cURL将跟随Location标题,并重定向到新的页面。但是是否有可能只获得新页面的标题,而实际上没有重定向?还是不可能?

I know that when I set CURLOPT_FOLLOWLOCATION to true, cURL will follow the Location header and redirect to new page. But is it possible only to get header of the new page without actually redirecting there? Or is it not possible?

推荐答案

否。您必须停用FOLLOWLOCATION,从响应中提取重定向网址,然后使用该网址发出新的HEAD请求。

No. You'd have to disable FOLLOWLOCATION, extract the redirect URL from the response, and then issue a new HEAD request with that url.

这篇关于卷曲,跟随位置,但只获得新位置的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆