2012-05-08 3 views
2

특정 URL은 항상 빈 HTTP 400 응답을 반환합니다 (다른 많은 URL은 정상적으로 작동합니다). 예 :Typhoeus로 요청을하는 경우, 특정 URL은 항상 빈 '400'응답을 반환합니다.

1.9.3p0 :002 > e = Typhoeus::Easy.new 

e.url = "http://us.asos.com/NW3/NW3-Highgate-Seersucker-Pinafore-Dress/Prod/pgeproduct.aspx?iid=1988231&cid=8799&sh=0&pge=0&pgesize=20&sort=-1&clr=Navy%252fivory&r=2" 

1.9.3p0 :004 > e.perform => 400 

1.9.3p0 :005 > y e 
--- !ruby/object:Typhoeus::Easy 
curl_return_code: 0 
headers: {} 

method: :get 
response_body: "" 
response_header: | 
    HTTP/1.1 400 Bad Request 
    Content-Type: text/html 
    Server: Microsoft-IIS/7.0 
    Content-Length: 0 
    Vary: Accept-Encoding 
    Date: Mon, 07 May 2012 19:35:28 GMT 
    Connection: keep-alive 

ssl_version: :default 
url: http://us.asos.com/NW3/NW3-Highgate-Seersucker-Pinafore-Dress/Prod/pgeproduct.aspx?iid=1988231&cid=8799&sh=0&pge=0&pgesize=20&sort=-1&clr=Navy%252fivory&r=2 => nil 

는 반대로, 동일한 시스템에, 몇 초 후에는 명령 줄 cURL을 통해 작동합니다

[email protected]:~/fashism$ curl -I "http://us.asos.com/NW3/NW3-Highgate-Seersucker-Pinafore-Dress/Prod/pgeproduct.aspx?iid=1988231&cid=8799&sh=0&pge=0&pgesize=20&sort=-1&clr=Navy%252fivory&r=2" 
HTTP/1.1 200 OK 
Cache-Control: private 
Content-Type: text/html;charset=utf-8 
Server: Microsoft-IIS/7.0 
X-AspNet-Version: 2.0.50727 
X-RuleEngine-Key: US1.0:ReferrerAnyOrNoneSiteDotUSPreferenceUSOrNone 
X-Powered-By: ASP.NET 
Date: Mon, 07 May 2012 19:54:03 GMT 
Connection: keep-alive 
Set-Cookie: AsosExecutionEngine=ExemptionTimeout=05/07/2012 20:14; expires=Tue, 07-May-2013 19:54:02 GMT; path=/ 
Set-Cookie: ASP.NET_SessionId=sd2hw4yu4l4jwmevc3gyan55; path=/; httponly 
Set-Cookie: asos=topcatidHitCount=1; expires=Tue, 07-May-2013 19:54:02 GMT; path=/ 
Set-Cookie: asos=topcatidHitCount=1&currencyid=1&topcatid=9057&customerguid=b5da62eb44de45eeadd2f36ec90332ca; expires=Tue, 07-May-2013 19:54:02 GMT; path=/ 
Set-Cookie: asosbasket=basketitemcount=0&basketitemtotalretailprice=0; expires=Mon, 07-May-2012 20:54:02 GMT; path=/ 
Set-Cookie: stop_mobi=yes; path=/ 

[email protected]:~/fashism$ 

어떤 아이디어? 도움을 주시면 해결책을 찾기 위해 나에게 방향을 제시해 주시더라도 크게 감사하겠습니다.

대단히 감사합니다! Typhoeus github issue에 내 대답에서 ~ 제임스

답변

2

는 :

서버는 요청 헤더의 수를 설정해야합니다.

시도 :

url = "http://us.asos.com/NW3/NW3-Highgate-Seersucker-Pinafore-Dress/Prod/pgeproduct.aspx?iid=1988231&cid=8799&sh=0&pge=0&pgesize=20&sort=-1&clr=Navy%252fivory&r=2" 
header = {"Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Cache-Control" => "no-cache", "Pragma" => "no-cache", "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"} 
response = Typhoeus::Request.get(url, headers: header, verbose: true, follow_location: true) 
관련 문제