Ruby on Rails analog HTTP request error: End of file reached

Source: Internet
Author: User
Tags ruby on rails

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.