How do you write Ruby with the same code as below?
Public Function MakeRequest ($url, $method, $postfields = NULL) { $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_httpheader, Array (' Expect: ')); if (' POST ' = = = $method) { curl_setopt ($ch, Curlopt_post, 1); if (!empty ($postfields)) { curl_setopt ($ch, Curlopt_postfields, $postfields); } } curl_setopt ($ch, Curlopt_connecttimeout, $this->_connecttimeout); curl_setopt ($ch, Curlopt_timeout, $this->_timeout); curl_setopt ($ch, curlopt_useragent, $this->_useragent); curl_setopt ($ch, Curlopt_ssl_verifypeer, false); curl_setopt ($ch, Curlopt_ssl_verifyhost, false); $output = curl_exec ($ch); Curl_close ($ch); return $output; }
THK
Reply content:
How do you write Ruby with the same code as below?
Public Function MakeRequest ($url, $method, $postfields = NULL) { $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_httpheader, Array (' Expect: ')); if (' POST ' = = = $method) { curl_setopt ($ch, Curlopt_post, 1); if (!empty ($postfields)) { curl_setopt ($ch, Curlopt_postfields, $postfields); } } curl_setopt ($ch, Curlopt_connecttimeout, $this->_connecttimeout); curl_setopt ($ch, Curlopt_timeout, $this->_timeout); curl_setopt ($ch, curlopt_useragent, $this->_useragent); curl_setopt ($ch, Curlopt_ssl_verifypeer, false); curl_setopt ($ch, Curlopt_ssl_verifyhost, false); $output = curl_exec ($ch); Curl_close ($ch); return $output; }
THK
Require ' URI ' require ' net/http ' require ' OpenSSL ' def makerequest (URL, method, postfields= "", ishttps= False) Httpheader = {"Expect:" = = "" } uri = Uri (URL) response = Nil http = net::http.new ( Uri.host, Uri.port) if Ishttpshttp.use_ssl = Truehttp.verify_mode = Openssl::ssl::verify_none End Http.start () response = Http.send_request (method, Uri.path, Postfields, httpheader) Ret_code = Response.code; Ret_str = Response.body; return ret_str; End
Recommend a different programming language conversion between the project matrix, landlord can see
http://langlangmatrix.com/