Ruby-http,net/http,httpclient:can';t解析www.victoriassecret.com
我使用的是Ruby-http,net/http,httpclient:can';t解析www.victoriassecret.com,ruby,amazon-ec2,Ruby,Amazon Ec2,我使用的是httpclientgem,它在Windows上运行良好,刚刚移动到AWS EC2,试用后得到以下响应: = Response HTTP/1.1 920 Unknown Content-Type: text/html Date: Wed, 21 Oct 2015 21:42:51 GMT Connection: Keep-Alive Content-Length: 23 <h1>File not found</h1>#<HTTP::Message:0x
httpclient
gem,它在Windows上运行良好,刚刚移动到AWS EC2,试用后得到以下响应:
= Response
HTTP/1.1 920 Unknown
Content-Type: text/html
Date: Wed, 21 Oct 2015 21:42:51 GMT
Connection: Keep-Alive
Content-Length: 23
<h1>File not found</h1>#<HTTP::Message:0x000000023f5168
@http_body=
#<HTTP::Message::Body:0x000000023f50a0
@body="<h1>File not found</h1>",
@chunk_size=nil,
@positions=nil,
@size=0>,
@http_header=
#<HTTP::Message::Headers:0x000000023f5140
@body_charset=nil,
@body_date=nil,
@body_encoding=#<Encoding:ASCII-8BIT>,
@body_size=0,
@body_type=nil,
@chunked=false,
@dumped=false,
@header_item=
[["Content-Type", "text/html"],
["Date", "Wed, 21 Oct 2015 21:42:51 GMT"],
["Connection", "Keep-Alive"],
["Content-Length", "23"]],
@http_version="1.1",
@is_request=false,
@reason_phrase="Unknown",
@request_absolute_uri=nil,
@request_method="GET",
@request_query=nil,
@request_uri=
#<URI::HTTPS:0x000000023f58c0 URL:https://www.victoriassecret.com/pink/new-and-now>,
@status_code=920>,
@peer_cert=
#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x000000024ebe00>, issuer=#<OpenSSL::X509::Name:0x000000024ebec8>, serial=#<OpenSSL::BN:0x000000024de110>, not_before=2015-05-27 00:00:00 UTC, not_after=2017-05-26 23:59:59 UTC>,
@previous=nil>
=响应
HTTP/1.1 920未知
内容类型:text/html
日期:2015年10月21日星期三格林威治时间21:42:51
连接:保持活力
内容长度:23
未找到文件#,
@http_头=
#,
@对等证书=
#,
@先前=无>
它不仅适用于此网站,
httpclient-gethttps://google.com
例如,它可以正常工作。但在Windows上,我从httpclient-get获得正常响应https://www.victoriassecret.com
。但是当使用标准的NET/HTTP库时,我在Windows上得到了相同的920响应。这与ec2无关。它很可能与各种http库实现发送的用户代理头有关
例如,他们显然不喜欢“wget”:
curl -A "Wget/1.13.4 (linux-gnu)" -v https://www.victoriassecret.com
* Rebuilt URL to: https://www.victoriassecret.com/
* Trying 98.158.54.100...
* Connected to www.victoriassecret.com (98.158.54.100) port 443 (#0)
* TLS 1.2 # truncated
> GET / HTTP/1.1
> Host: www.victoriassecret.com
> User-Agent: Wget/1.13.4 (linux-gnu)
> Accept: */*
>
< HTTP/1.1 910 Unknown
< Content-Type: text/html
< Date: Thu, 22 Oct 2015 01:16:31 GMT
< Connection: Keep-Alive
< Content-Length: 23
<
* Connection #0 to host www.victoriassecret.com left intact
<h1>File not found</h1>%
curl-A“Wget/1.13.4(linux gnu)”-vhttps://www.victoriassecret.com
*重新生成的URL到:https://www.victoriassecret.com/
*正在尝试98.158.54.100。。。
*已连接到www.victoriassecret.com(98.158.54.100)端口443(#0)
*TLS 1.2#截断
>GET/HTTP/1.1
>主持人:www.victoriassecret.com
>用户代理:Wget/1.13.4(linux gnu)
>接受:*/*
>
这与ec2无关。它很可能与各种http库实现发送的用户代理头有关
例如,他们显然不喜欢“wget”:
curl -A "Wget/1.13.4 (linux-gnu)" -v https://www.victoriassecret.com
* Rebuilt URL to: https://www.victoriassecret.com/
* Trying 98.158.54.100...
* Connected to www.victoriassecret.com (98.158.54.100) port 443 (#0)
* TLS 1.2 # truncated
> GET / HTTP/1.1
> Host: www.victoriassecret.com
> User-Agent: Wget/1.13.4 (linux-gnu)
> Accept: */*
>
< HTTP/1.1 910 Unknown
< Content-Type: text/html
< Date: Thu, 22 Oct 2015 01:16:31 GMT
< Connection: Keep-Alive
< Content-Length: 23
<
* Connection #0 to host www.victoriassecret.com left intact
<h1>File not found</h1>%
curl-A“Wget/1.13.4(linux gnu)”-vhttps://www.victoriassecret.com
*重新生成的URL到:https://www.victoriassecret.com/
*正在尝试98.158.54.100。。。
*已连接到www.victoriassecret.com(98.158.54.100)端口443(#0)
*TLS 1.2#截断
>GET/HTTP/1.1
>主持人:www.victoriassecret.com
>用户代理:Wget/1.13.4(linux gnu)
>接受:*/*
>
在Mac OSX 10.10.2上,我得到=响应HTTP/1.1 301永久移动内容类型:text/html日期:Wed,2015年10月21日21:56:13 GMT地点:https://www.victoriassecret.com/ 连接:保持活动内容长度:0
尝试向发出请求,但在Windows上我可以这样做。Gem'http'不起作用你有没有想过这个问题,我也在ec2上看到过,但在macOn Mac OSX 10.10.2上运行正常,我得到=响应http/1.1 301永久移动内容类型:text/html日期:Wed,2015年10月21日21:56:13格林尼治标准时间地点:https://www.victoriassecret.com/ 连接:保持活动内容长度:0
尝试向发出请求,但在Windows上我可以这样做。Gem'http'不工作,你有没有想过这个问题,我也在ec2上看到过,但在macNope上工作正常,这个特定的站点不是这样的。在ec2上试用最新的Chrome用户代理,仍然会得到奇怪的910状态代码:curl-A“Mozilla/5.0(Macintosh;Intel Mac OS X 10_11_4)AppleWebKit/537.36(KHTML,如Gecko)Chrome/49.0.2623.110 Safari/537.36”-I-L HTTP/1.1 910未知内容类型:文本/普通日期:Fri,2016年4月15日00:13:13 GMT连接:保持活动内容长度:0不,此特定网站并非如此。在ec2上试用最新的Chrome用户代理,仍然会得到奇怪的910状态代码:curl-A“Mozilla/5.0(Macintosh;Intel Mac OS X 10_11_4)AppleWebKit/537.36(KHTML,如Gecko)Chrome/49.0.2623.110 Safari/537.36”-I-L HTTP/1.1 910未知内容类型:文本/普通日期:2016年4月15日星期五00:13:13 GMT连接:保持活动内容长度:0