Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable frozen_string_literal #65

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/net/http.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# = net/http.rb
#
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def connect
write_timeout: @write_timeout,
continue_timeout: @continue_timeout,
debug_output: @debug_output)
buf = "CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n"
buf = +"CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n"
buf << "Host: #{@address}:#{@port}\r\n"
if proxy_user
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m0')
Expand Down
2 changes: 1 addition & 1 deletion lib/net/http/backward.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
# for backward compatibility

# :enddoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/net/http/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
module Net
# Net::HTTP exception class.
# You cannot use Net::HTTPExceptions directly; instead, you must use
Expand Down
8 changes: 4 additions & 4 deletions lib/net/http/generic_request.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
# HTTPGenericRequest is the parent of the Net::HTTPRequest class.
# Do not use this directly; use a subclass of Net::HTTPRequest.
#
Expand Down Expand Up @@ -110,7 +110,7 @@ def set_body_internal(str) #:nodoc: internal use only
raise ArgumentError, "both of body argument and HTTPRequest#body set" if str and (@body or @body_stream)
self.body = str if str
if @body.nil? && @body_stream.nil? && @body_data.nil? && request_body_permitted?
self.body = ''
self.body = +''
end
end

Expand Down Expand Up @@ -239,7 +239,7 @@ def encode_multipart_form_data(out, params, opt)
boundary ||= SecureRandom.urlsafe_base64(40)
chunked_p = chunked?

buf = ''
buf = +''
params.each do |key, value, h={}|
key = quote_string(key, charset)
filename =
Expand Down Expand Up @@ -324,7 +324,7 @@ def write_header(sock, ver, path)
if /[\r\n]/ =~ reqline
raise ArgumentError, "A Request-Line must not contain CR or LF"
end
buf = ""
buf = +""
buf << reqline << "\r\n"
each_capitalized do |k,v|
buf << "#{k}: #{v}\r\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/net/http/header.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
# The HTTPHeader module defines methods for reading and writing
# HTTP headers.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/net/http/proxy_delta.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
module Net::HTTP::ProxyDelta #:nodoc: internal use only
private

Expand Down
2 changes: 1 addition & 1 deletion lib/net/http/request.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
# HTTP request class.
# This class wraps together the request header and the request path.
# You cannot use this class directly. Instead, you should use one of its
Expand Down
2 changes: 1 addition & 1 deletion lib/net/http/requests.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#
# HTTP/1.1 methods --- RFC2616
#
Expand Down
4 changes: 2 additions & 2 deletions lib/net/http/response.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
# HTTP response class.
#
# This class wraps together the response header and the response body (the
Expand Down Expand Up @@ -513,7 +513,7 @@ def procdest(dest, block)
if block
Net::ReadAdapter.new(block)
else
dest || ''
dest || +''
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/net/https.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
=begin

= net/https -- SSL/TLS enhancement for Net::HTTP.
Expand Down
2 changes: 1 addition & 1 deletion test/net/http/test_buffered_io.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
require 'test/unit'
require 'net/http'
require 'stringio'
Expand Down
14 changes: 7 additions & 7 deletions test/net/http/test_http.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: US-ASCII
# frozen_string_literal: false
# frozen_string_literal: true
require 'test/unit'
require 'net/http'
require 'stringio'
Expand Down Expand Up @@ -362,7 +362,7 @@ def _test_get__get(http)
end

def _test_get__iter(http)
buf = ''
buf = +''
res = http.get('/') {|s| buf << s }
assert_kind_of Net::HTTPResponse, res
# assert_kind_of String, res.body
Expand All @@ -378,7 +378,7 @@ def _test_get__iter(http)
end

def _test_get__chunked(http)
buf = ''
buf = +''
res = http.get('/') {|s| buf << s }
assert_kind_of Net::HTTPResponse, res
# assert_kind_of String, res.body
Expand Down Expand Up @@ -685,7 +685,7 @@ def _test_request__file(http)
assert_not_nil res['content-length']
assert_equal $test_net_http_data.size, res['content-length'].to_i
end
f = StringIO.new("".force_encoding("ASCII-8BIT"))
f = StringIO.new("".b)
res.read_body f
assert_equal $test_net_http_data.bytesize, f.string.bytesize
assert_equal $test_net_http_data.encoding, f.string.encoding
Expand Down Expand Up @@ -828,7 +828,7 @@ def test_set_form
data = [
['name', 'Gonbei Nanashi'],
['name', "\u{540d}\u{7121}\u{3057}\u{306e}\u{6a29}\u{5175}\u{885b}"],
['s"i\o', StringIO.new("\u{3042 3044 4e9c 925b}")],
['s"i\o', StringIO.new(+"\u{3042 3044 4e9c 925b}")],
["file", file, filename: "ruby-test"]
]
expected = <<"__EOM__".gsub(/\n/, "\r\n")
Expand Down Expand Up @@ -990,7 +990,7 @@ class TestNetHTTPContinue < Test::Unit::TestCase
include TestNetHTTPUtils

def logfile
@debug = StringIO.new('')
@debug = StringIO.new(+'')
end

def mount_proc(&block)
Expand Down Expand Up @@ -1090,7 +1090,7 @@ class TestNetHTTPSwitchingProtocols < Test::Unit::TestCase
include TestNetHTTPUtils

def logfile
@debug = StringIO.new('')
@debug = StringIO.new(+'')
end

def mount_proc(&block)
Expand Down
2 changes: 1 addition & 1 deletion test/net/http/test_http_request.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
require 'net/http'
require 'test/unit'

Expand Down
2 changes: 1 addition & 1 deletion test/net/http/test_httpheader.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
require 'net/http'
require 'test/unit'

Expand Down
18 changes: 9 additions & 9 deletions test/net/http/test_httpresponse.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: US-ASCII
# frozen_string_literal: false
# frozen_string_literal: true
require 'net/http'
require 'test/unit'
require 'stringio'
Expand Down Expand Up @@ -189,12 +189,12 @@ def test_read_body_body_encoding_true_with_iso_8859_1_content_type_header
body = res.read_body
end

assert_equal "hello\u1234".force_encoding("ISO-8859-1"), body
assert_equal (+"hello\u1234").force_encoding("ISO-8859-1"), body
assert_equal Encoding::ISO_8859_1, body.encoding
end

def test_read_body_body_encoding_true_with_utf8_meta_charset
res_body = "<html><meta charset=\"utf-8\">hello\u1234</html>"
res_body = +"<html><meta charset=\"utf-8\">hello\u1234</html>"
io = dummy_io(<<EOS)
HTTP/1.1 200 OK
Connection: close
Expand All @@ -218,7 +218,7 @@ def test_read_body_body_encoding_true_with_utf8_meta_charset
end

def test_read_body_body_encoding_true_with_iso8859_1_meta_charset
res_body = "<html><meta charset=\"iso-8859-1\">hello\u1234</html>"
res_body = +"<html><meta charset=\"iso-8859-1\">hello\u1234</html>"
io = dummy_io(<<EOS)
HTTP/1.1 200 OK
Connection: close
Expand All @@ -242,7 +242,7 @@ def test_read_body_body_encoding_true_with_iso8859_1_meta_charset
end

def test_read_body_body_encoding_true_with_utf8_meta_content_charset
res_body = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'>hello\u1234</html>"
res_body = +"<meta http-equiv='content-type' content='text/html; charset=UTF-8'>hello\u1234</html>"
io = dummy_io(<<EOS)
HTTP/1.1 200 OK
Connection: close
Expand All @@ -266,7 +266,7 @@ def test_read_body_body_encoding_true_with_utf8_meta_content_charset
end

def test_read_body_body_encoding_true_with_iso8859_1_meta_content_charset
res_body = "<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>hello\u1234</html>"
res_body = +"<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>hello\u1234</html>"
io = dummy_io(<<EOS)
HTTP/1.1 200 OK
Connection: close
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_read_body_block

res = Net::HTTPResponse.read_new(io)

body = ''
body = +''

res.reading_body io, true do
res.read_body do |chunk|
Expand Down Expand Up @@ -580,7 +580,7 @@ def test_read_body_string

res = Net::HTTPResponse.read_new(io)

body = ''
body = +''

res.reading_body io, true do
res.read_body body
Expand Down Expand Up @@ -704,7 +704,7 @@ def test_inspect_response
assert_equal '#<Net::HTTPUnknownResponse ??? test response readbody=false>', res.inspect

res = Net::HTTPUnknownResponse.new('1.0', '???', 'test response')
socket = Net::BufferedIO.new(StringIO.new('test body'))
socket = Net::BufferedIO.new(StringIO.new(+'test body'))
res.reading_body(socket, true) {}
assert_equal '#<Net::HTTPUnknownResponse ??? test response readbody=true>', res.inspect
end
Expand Down
2 changes: 1 addition & 1 deletion test/net/http/test_httpresponses.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
require 'net/http'
require 'test/unit'

Expand Down
2 changes: 1 addition & 1 deletion test/net/http/test_https.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
require "test/unit"
require_relative "utils"
begin
Expand Down
2 changes: 1 addition & 1 deletion test/net/http/test_https_proxy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
begin
require 'net/https'
rescue LoadError
Expand Down
2 changes: 1 addition & 1 deletion test/net/http/utils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
require 'webrick'
begin
require "webrick/https"
Expand Down