How can I use HTTParty with UTF-8 encoding?

房东的猫 提交于 2019-12-24 04:32:08

问题


I have a URL like http://example.com/tag/София/new.json and I want to make a GET request with HTTParty. When I do:

HTTPArty.get "http://example.com/tag/София/new.json

I get:

URI::InvalidURIError at /
bad URI(is not URI?): link here

Any ideas how to handle this ?


回答1:


The standard says "encode the URL as UTF-8, then represent multi-byte sequences as percent-escaped octets." In your case,

http://example.com/tag/%D0%A1%D0%BE%D1%84%D0%B8%D1%8F/new.json


来源:https://stackoverflow.com/questions/1981999/how-can-i-use-httparty-with-utf-8-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!