test/test_proxy_pass.rb in yahns-1.11.0 vs test/test_proxy_pass.rb in yahns-1.12.0
- old
+ new
@@ -1,7 +1,8 @@
-# Copyright (C) 2015 all contributors <yahns-public@yhbt.net>
-# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
+# Copyright (C) 2015-2016 all contributors <yahns-public@yhbt.net>
+# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
+# frozen_string_literal: true
require_relative 'server_helper'
require 'json'
require 'digest'
begin
require 'kcar'
@@ -388,13 +389,13 @@
quit_wait pid2
end
def check_pipelining(host, port)
pl = TCPSocket.new(host, port)
- r1 = ''
- r2 = ''
- r3 = ''
+ r1 = ''.dup
+ r2 = ''.dup
+ r3 = ''.dup
Timeout.timeout(60) do
pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\nGET /"
until r1 =~ /hi\n/
r1 << pl.readpartial(666)
end
@@ -413,32 +414,32 @@
r3 << pl.readpartial(666)
end
# ensure stuff still works after a chunked upload:
pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\nP"
- after_up = ''
+ after_up = ''.dup
until after_up =~ /hi\n/
after_up << pl.readpartial(666)
end
re = /^Date:[^\r\n]+/
assert_equal after_up.sub(re, ''), r1.sub(re, '')
# another upload, this time without chunking
pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n"
pl.write "Content-Length: 8\r\n\r\n"
pl.write "identity"
- identity = ''
+ identity = ''.dup
until identity =~ /identity/
identity << pl.readpartial(666)
end
assert_match %r{identity\z}, identity
assert_match %r{\AHTTP/1\.1 201\b}, identity
# ensure stuff still works after an identity upload:
pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n"
- after_up = ''
+ after_up = ''.dup
until after_up =~ /hi\n/
after_up << pl.readpartial(666)
end
re = /^Date:[^\r\n]+/
assert_equal after_up.sub(re, ''), r1.sub(re, '')
@@ -507,12 +508,12 @@
def check_slow_giant_body(host, port)
s = TCPSocket.new(host, port)
s.write "GET /giant-body HTTP/1.0\r\n\r\n"
sleep 0.1
- str = ''
- buf = ''
+ str = ''.dup
+ buf = ''.dup
assert_raises(EOFError) { loop { str << s.readpartial(400, buf) } }
h, b = str.split(/\r\n\r\n/, 2)
assert_equal OMFG, b
assert_match %r{\AHTTP/1\.1 200\b}, h
ensure
@@ -521,12 +522,12 @@
def check_slow_read_headers(host, port)
s = TCPSocket.new(host, port)
s.write "GET /big-headers HTTP/1.1\r\nHost: example.com\r\n\r\n"
s.write "HEAD /big-headers HTTP/1.0\r\n\r\n"
- buf = ''
- res = ''
+ buf = ''.dup
+ res = ''.dup
sleep 0.1
begin
res << s.readpartial(32786, buf)
rescue EOFError
break
@@ -550,11 +551,11 @@
].map do |x|
Thread.new do
s = TCPSocket.new(host, port)
s.write "GET /response-trailer HTTP/1.1\r\n#{x}" \
"Host: example.com\r\n\r\n"
- res = ''
- buf = ''
+ res = ''.dup
+ buf = ''.dup
Timeout.timeout(60) do
until res =~ /Foo: bar\r\n\r\n\z/
res << s.readpartial(16384, buf)
end
end