in the article The rest API in Ruby on Rails uses an example of creating your own online translator tool based on cloud Platform + cloud services , using Ruby's net::http to initiate HTTP requests to access language translation services on IBM Bluemix , Tip: End offile reached
The code is as follows:
Auth = "C9819718-4660-441c-9df7-07398950ea44:quvrjpqwsgox"; surl = "https://" + auth + "@gateway. watsonplatform.net/ language-translation/api/v2/translate?source=en&target=es&text= "+ @txt; uri = Uri.parse (surl); Begin #开始http = Net::http.new (Uri.host, uri.port)Http.use_ssl = truerequest = Net::http::get.new (Uri.request_uri) response = Http.request (Request) @result = "{\" text\ ": \" #{response.body}\ "}"; rescue@result = "{\" error\ ": \" #{$!}! \ "}"; end
See this error message, just beginning to think is a grammatical problem, but how can not find the problem;
Later notice that the URL is the beginning of the HTTPS, thinking that it might be the problem,
After searching, sure enough is required to set: Http.use_ssl = True
After setting up, come out with a new question: Ssl_connect returned=1 errno=0 state=sslv3 Read server certificate b:certificate verify failed
Ruby on Rails analog HTTP request error: End of file reached