Linux 如何获取HTTPS请求的响应号
我想使用Linux命令来获取HTTPS请求的响应号,而不是HTTP请求。根据我目前的知识,Linux 如何获取HTTPS请求的响应号,linux,shell,curl,https,wget,Linux,Shell,Curl,Https,Wget,我想使用Linux命令来获取HTTPS请求的响应号,而不是HTTP请求。根据我目前的知识,wget和curl可以实现目标 例如,给定地址,我打算使用以下命令: 使用curl:curl-Ihttps://asunnot.oikotie.fi/vuokrattavat-asunnot/espoo/13874872 使用wget:wget--spider-S'https://asunnot.oikotie.fi/vuokrattavat-asunnot/espoo/13874872“ 这两个请求都
wget
和curl
可以实现目标
例如,给定地址,我打算使用以下命令:
- 使用curl:
curl-Ihttps://asunnot.oikotie.fi/vuokrattavat-asunnot/espoo/13874872
- 使用wget:
wget--spider-S'https://asunnot.oikotie.fi/vuokrattavat-asunnot/espoo/13874872“
有人能帮忙吗?如何获得正确的响应号而不是第一个直接405 使用
curl
您需要设置-A,--user-agent
选项,因为某些HTTP服务器/CGI需要填充头user-agent
curl -I 'https://asunnot.oikotie.fi/vuokrattavat-asunnot/espoo/13874872' -A "Mozilla/5.0"
输出:
HTTP/1.1 200 OK
Date: Tue, 14 Nov 2017 13:56:11 GMT
Content-Type: text/html
Connection: keep-alive
Server: nginx
Vary: Accept-Encoding
X-DB: 5
X-DW: 0
X-DZ: 93.72.75.166
X-VID: 93.72.75.166:14CDB9B4-DE01-3FAA-AFF5-65BC2F771745
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: private, no-cache, no-store, must-revalidate
Edge-Control: no-store, bypass-cache
Surrogate-Control: no-store, bypass-cache
-A,--user-agent
(HTTP)指定要发送到HTTP服务器的用户代理字符串。如果此字段不正确,一些做得很差的CGI将失败 设置为
“Mozilla/4.0”
。要对字符串中的空格进行编码,请使用单引号将字符串括起来。这个可以
当然,也可以使用-H,--header
选项进行设置
服务器使用HTTP代码405应答,因为它拒绝您发送的
curl
命令的User-Agent
头。从服务器配置或网站应用程序本身来看,这显然是一种不良行为。服务器应该用HTTP 400进行应答
无论如何,对于给定的URL,以下内容可以正常工作:
curl -I -H "User-Agent: Mozilla/5.0" <url>
curl-I-H“用户代理:Mozilla/5.0”
详细说明正确的回复号码