# File lib/webmock/response.rb, line 92
92: def ==(other)
93: self.body == other.body &&
94: self.headers === other.headers &&
95: self.status == other.status &&
96: self.exception == other.exception &&
97: self.should_timeout == other.should_timeout
98: end
# File lib/webmock/response.rb, line 38
38: def body
39: @body || ''
40: end
# File lib/webmock/response.rb, line 42
42: def body=(body)
43: @body = body
44: stringify_body!
45: end
# File lib/webmock/response.rb, line 83
83: def evaluate!(request_signature)
84: self.body = @body.call(request_signature) if @body.is_a?(Proc)
85: self.headers = @headers.call(request_signature) if @headers.is_a?(Proc)
86: self.status = @status.call(request_signature) if @status.is_a?(Proc)
87: @should_timeout = @should_timeout.call(request_signature) if @should_timeout.is_a?(Proc)
88: @exception = @exception.call(request_signature) if @exception.is_a?(Proc)
89: self
90: end
# File lib/webmock/response.rb, line 55
55: def exception
56: @exception
57: end
# File lib/webmock/response.rb, line 59
59: def exception=(exception)
60: @exception = case exception
61: when String then StandardError.new(exception)
62: when Class then exception.new('Exception from WebMock')
63: when Exception then exception
64: end
65: end
# File lib/webmock/response.rb, line 27
27: def headers
28: @headers
29: end
# File lib/webmock/response.rb, line 31
31: def headers=(headers)
32: @headers = headers
33: if @headers && !@headers.is_a?(Proc)
34: @headers = Util::Headers.normalize_headers(@headers)
35: end
36: end
# File lib/webmock/response.rb, line 75
75: def options=(options)
76: self.headers = options[:headers]
77: self.status = options[:status]
78: self.body = options[:body]
79: self.exception = options[:exception]
80: @should_timeout = options[:should_timeout]
81: end
# File lib/webmock/response.rb, line 67
67: def raise_error_if_any
68: raise @exception if @exception
69: end
# File lib/webmock/response.rb, line 71
71: def should_timeout
72: @should_timeout == true
73: end
# File lib/webmock/response.rb, line 110
110: def read_raw_response(raw_response)
111: if raw_response.is_a?(IO)
112: string = raw_response.read
113: raw_response.close
114: raw_response = string
115: end
116: socket = ::Net::BufferedIO.new(raw_response)
117: response = ::Net::HTTPResponse.read_new(socket)
118: transfer_encoding = response.delete('transfer-encoding') #chunks were already read by curl
119: response.reading_body(socket, true) {}
120:
121: options = {}
122: options[:headers] = {}
123: response.each_header {|name, value| options[:headers][name] = value}
124: options[:headers]['transfer-encoding'] = transfer_encoding if transfer_encoding
125: options[:body] = response.read_body
126: options[:status] = [response.code.to_i, response.message]
127: options
128: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.