10: def handle(ctx, params)
11: params[:response] = @response
12: body = StringIO.new
13: total = 0
14: @response.read_body { |part|
15: total += part.length
16: body.write(part)
17: Mechanize.log.debug("Read #{total} bytes") if Mechanize.log
18: }
19: body.rewind
20:
21: res_klass = Net::HTTPResponse::CODE_TO_OBJ[@response.code.to_s]
22: raise ResponseCodeError.new(@response) unless res_klass
23:
24:
25: unless res_klass <= Net::HTTPRedirection
26: raise EOFError if (!params[:request].is_a?(Net::HTTP::Head)) && @response.content_length() && @response.content_length() != total
27: end
28:
29: @response.each_header { |k,v|
30: Mechanize.log.debug("response-header: #{ k } => #{ v }")
31: } if Mechanize.log
32:
33: params[:response_body] = body
34: params[:res_klass] = res_klass
35: super
36: end