201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
# File 'lib/mechanize/test_case.rb', line 201
def do_GET(req, res)
if req['Accept-Encoding'] =~ /gzip/
if name = req.query['file'] then
open("#{Mechanize::TestCase::TEST_DIR}/htdocs/#{name}", 'r') do |io|
string = ""
zipped = StringIO.new string, 'w'
Zlib::GzipWriter.wrap zipped do |gz|
gz.write io.read
end
res.body = string
end
else
res.body = ''
end
res['Content-Encoding'] = req['X-ResponseContentEncoding'] || 'gzip'
res['Content-Type'] = "text/html"
else
res.code = 400
res.body = 'no gzip'
end
end
|