1

I'm using Curb to get various URLs, and if the response is 200, I get what I need. However, if the response is a redirect, Curb doesn't seem to follow the redirects, even though I ask it to - e.g:

easy = Curl::Easy.new
easy.follow_location = true
easy.max_redirects = 3 
easy.url = "http://stats.berr.gov.uk/ed/vat/VATStatsTables2a2d2007.xls"
easy.perform

=> Curl::Err::GotNothingError: Curl::Err::GotNothingError
from /Users/stuart/.rvm/gems/ruby-2.0.0-p0@datakitten/gems/curb-0.8.4/lib/curl/easy.rb:60:in `perform'

However, if I do curl -L http://stats.berr.gov.uk/ed/vat/VATStatsTables2a2d2007.xls on the command line, I get the expected response. What am I doing wrong?

4

1 回答 1

2

如果您不提供用户代理,这听起来像此服务器返回一个空回复 [1]。

要解决您的问题,只需设置一个:

...
easy.useragent = "curb"
easy.perform

[1]:curl -A '' -L http://stats.berr.gov.uk/...给出(52) Empty reply from server.

于 2013-07-30T11:52:31.293 回答