@@ -5,8 +5,8 @@ var util = require('util')
55module . exports = function ( source , options ) {
66 var self = this
77 var code = [ ]
8- code . push ( ' require \ 'uri\'' )
9- code . push ( ' require \ 'net/http\'' )
8+ code . push ( " require 'uri'" )
9+ code . push ( " require 'net/http'" )
1010 code . push ( null )
1111
1212 // To support custom methods we check for the supported methods
@@ -15,10 +15,9 @@ module.exports = function (source, options) {
1515 var methods = [ 'GET' , 'POST' , 'HEAD' , 'DELETE' , 'PATCH' , 'PUT' , 'OPTIONS' , 'COPY' , 'LOCK' , 'UNLOCK' , 'MOVE' , 'TRACE' ]
1616 var capMethod = method . charAt ( 0 ) + method . substring ( 1 ) . toLowerCase ( )
1717 if ( methods . indexOf ( method ) < 0 ) {
18- code . push ( 'class Net::HTTP::%s < Net::HTTPRequest' )
1918 code . push ( util . format ( 'class Net::HTTP::%s < Net::HTTPRequest' , capMethod ) )
20- code . push ( util . format ( ' METHOD = \ '%s\'' , method . toUpperCase ( ) ) )
21- code . push ( util . format ( ' REQUEST_HAS_BODY = \ '%s\'' , self . source . postData . text ? 'true' : 'false' ) )
19+ code . push ( util . format ( " METHOD = '%s'" , method . toUpperCase ( ) ) )
20+ code . push ( util . format ( " REQUEST_HAS_BODY = '%s'" , self . source . postData . text ? 'true' : 'false' ) )
2221 code . push ( ' RESPONSE_HAS_BODY = true' )
2322 code . push ( 'end' )
2423 code . push ( null )
@@ -28,7 +27,7 @@ module.exports = function (source, options) {
2827
2928 code . push ( null )
3029
31- code . push ( 'conn = Net::HTTP.new(url.host, url.port)' )
30+ code . push ( 'http = Net::HTTP.new(url.host, url.port)' )
3231
3332 if ( source . uriObj . protocol === 'https:' ) {
3433 code . push ( 'http.use_ssl = true' )
@@ -52,7 +51,7 @@ module.exports = function (source, options) {
5251
5352 code . push ( null )
5453
55- code . push ( 'response = conn .request(request)' )
54+ code . push ( 'response = http .request(request)' )
5655 code . push ( 'puts response.read_body' )
5756
5857 return code . join ( '\n' )
@@ -61,6 +60,6 @@ module.exports = function (source, options) {
6160module . exports . info = {
6261 key : 'native' ,
6362 title : 'net::http' ,
64- link : 'http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTPGenericRequest .html' ,
65- description : 'Ruby request client'
63+ link : 'http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP .html' ,
64+ description : 'Ruby HTTP client'
6665}
0 commit comments