diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/net/http/generic_request.rb | 17 |
2 files changed, 14 insertions, 9 deletions
@@ -1,3 +1,9 @@ +Wed Aug 6 02:16:43 2014 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/net/http/generic_request.rb + (Net::HTTP::GenericRequest#initialize): + optimize object allocation. + Wed Aug 6 01:16:47 2014 NARUSE, Yui <naruse@ruby-lang.org> * lib/uri/generic.rb (URI::Generic#path_query): remove a private method. diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb index b51034c7ea..0b70630d89 100644 --- a/lib/net/http/generic_request.rb +++ b/lib/net/http/generic_request.rb @@ -14,19 +14,18 @@ class Net::HTTPGenericRequest if URI === uri_or_path then @uri = uri_or_path.dup - host = @uri.hostname - host += ":#{@uri.port}" if @uri.port != @uri.class::DEFAULT_PORT - path = uri_or_path.request_uri + host = @uri.hostname.dup + host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port + @path = uri_or_path.request_uri + raise ArgumentError, "no HTTP request path given" unless @path else @uri = nil host = nil - path = uri_or_path + raise ArgumentError, "no HTTP request path given" unless uri_or_path + raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty? + @path = uri_or_path.dup end - raise ArgumentError, "no HTTP request path given" unless path - raise ArgumentError, "HTTP request path is empty" if path.empty? - @path = path - @decode_content = false if @response_has_body and Net::HTTP::HAVE_ZLIB then @@ -44,7 +43,7 @@ class Net::HTTPGenericRequest initialize_http_header initheader self['Accept'] ||= '*/*' self['User-Agent'] ||= 'Ruby' - self['Host'] ||= host + self['Host'] ||= host if host @body = nil @body_stream = nil @body_data = nil |