Class Net::HTTP
In: lib/net_fix.rb
Parent: Object

Methods

request  

Public Instance methods

[Source]

     # File lib/net_fix.rb, line 127
127:     def request(req, body = nil, &block)  # :yield: +response+
128:       unless started?
129:         start {
130:           req['connection'] ||= 'close'
131:           return request(req, body, &block)
132:         }
133:       end
134:       if proxy_user()
135:         unless use_ssl?
136:           req.proxy_basic_auth proxy_user(), proxy_pass()
137:         end
138:       end
139:       # set body
140:       req.set_body_internal body
141:       begin_transport req
142:         # if we expect 100-continue then send a header first
143:         send_only = ((req.is_a?(Post)||req.is_a?(Put)) && (req['expect']=='100-continue')) ? :header : nil
144:         req.exec @socket, @curr_http_version, edit_path(req.path), send_only
145:         begin
146:           res = HTTPResponse.read_new(@socket)
147:           # if we expected 100-continue then send a body
148:           if res.is_a?(HTTPContinue) && send_only && req['content-length'].to_i > 0
149:             req.exec @socket, @curr_http_version, edit_path(req.path), :body
150:           end
151:         end while res.kind_of?(HTTPContinue)
152:         res.reading_body(@socket, req.response_body_permitted?) {
153:           yield res if block_given?
154:         }
155:       end_transport req, res
156:       res
157:     end

[Validate]