响应重定向编码的RestClient错误

时间:2015-02-22 17:15:23

标签: ruby encoding uri rest-client

尝试获取此页面时:

resp = RestClient.get("http://www.radios.com.br/aovivo/XXXX/24924")

我收到此错误:

URI::InvalidURIError: bad URI(is not URI?): http://www.radios.com.br/aovivo/Radio-Gospel-Ajduk?s/24924
    from /Users/danicuki/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/common.rb:176:in `split'
    from /Users/danicuki/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/common.rb:211:in `parse'

我认为这种情况正在发生,因为响应重定向网址存在编码问题。怎么解决?

2 个答案:

答案 0 :(得分:0)

URI中的非ASCII字符必须是urlencoded:

url = "http://www.radios.com.br/aovivo/XXXX/24924"
resp = RestClient.get(URI::encode(str))

答案 1 :(得分:0)

您需要为RestClient申请补丁:(在版本create or replace view test2_0111 as select CID, NAME, (select max(score) from pub.student_course t1 where t1.CID = t0.CID) as max_score from pub.course t0 中尚未修复)

2.1.0