File tree Expand file tree Collapse file tree 4 files changed +20
-9
lines changed Expand file tree Collapse file tree 4 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 12
12
- 2.4
13
13
- 2.5
14
14
- 2.6
15
+ - ruby-head
15
16
script :
16
17
- " bundle exec shindont"
17
18
- " bundle exec rake spec[progress]"
18
19
sudo : false
20
+
21
+ matrix :
22
+ allow_failures :
23
+ - rvm : ruby-head
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ def request_call(datum)
161
161
socket . write ( request ) # write out request + headers
162
162
while true # write out body with chunked encoding
163
163
chunk = datum [ :request_block ] . call
164
- binary_encode ( chunk )
164
+ chunk = binary_encode ( chunk )
165
165
if chunk . length > 0
166
166
socket . write ( chunk . length . to_s ( 16 ) << CR_NL << chunk << CR_NL )
167
167
else
@@ -180,10 +180,10 @@ def request_call(datum)
180
180
end
181
181
182
182
# if request + headers is less than chunk size, fill with body
183
- binary_encode ( request )
183
+ request = binary_encode ( request )
184
184
chunk = body . read ( [ datum [ :chunk_size ] - request . length , 0 ] . max )
185
185
if chunk
186
- binary_encode ( chunk )
186
+ chunk = binary_encode ( chunk )
187
187
socket . write ( request << chunk )
188
188
else
189
189
socket . write ( request ) # write out request + headers
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ def read_block(max_length)
237
237
end
238
238
239
239
def write_nonblock ( data )
240
- binary_encode ( data )
240
+ data = binary_encode ( data )
241
241
loop do
242
242
written = nil
243
243
begin
Original file line number Diff line number Diff line change @@ -12,7 +12,13 @@ module Utils
12
12
13
13
def binary_encode ( string )
14
14
if FORCE_ENC && string . encoding != Encoding ::ASCII_8BIT
15
- string . force_encoding ( 'BINARY' )
15
+ if string . frozen?
16
+ string . dup . force_encoding ( 'BINARY' )
17
+ else
18
+ string . force_encoding ( 'BINARY' )
19
+ end
20
+ else
21
+ string
16
22
end
17
23
end
18
24
@@ -89,29 +95,29 @@ def query_string(datum)
89
95
def split_header_value ( str )
90
96
return [ ] if str . nil?
91
97
str = str . dup . strip
92
- binary_encode ( str )
98
+ str = binary_encode ( str )
93
99
str . scan ( %r'\G ((?:"(?:\\ .|[^"])+?"|[^",]+)+)
94
100
(?:,\s *|\Z )'xn ) . flatten
95
101
end
96
102
97
103
# Escapes HTTP reserved and unwise characters in +str+
98
104
def escape_uri ( str )
99
105
str = str . dup
100
- binary_encode ( str )
106
+ str = binary_encode ( str )
101
107
str . gsub ( UNESCAPED ) { "%%%02X" % $1[ 0 ] . ord }
102
108
end
103
109
104
110
# Unescapes HTTP reserved and unwise characters in +str+
105
111
def unescape_uri ( str )
106
112
str = str . dup
107
- binary_encode ( str )
113
+ str = binary_encode ( str )
108
114
str . gsub ( ESCAPED ) { $1. hex . chr }
109
115
end
110
116
111
117
# Unescape form encoded values in +str+
112
118
def unescape_form ( str )
113
119
str = str . dup
114
- binary_encode ( str )
120
+ str = binary_encode ( str )
115
121
str . gsub! ( /\+ / , ' ' )
116
122
str . gsub ( ESCAPED ) { $1. hex . chr }
117
123
end
You can’t perform that action at this time.
0 commit comments