Method: HTTPClient::Session#query

Defined in:
lib/httpclient.rb

#query(req) ⇒ Object

Send a request to the server



1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
# File 'lib/httpclient.rb', line 1167

def query(req)
  connect() if @state == :INIT
  begin
    timeout(@send_timeout) do
      set_header(req)
      req.dump(@socket)
      # flush the IO stream as IO::sync mode is false
      @socket.flush unless @socket_sync
    end
  rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
    close
    raise KeepAliveDisconnected.new
  rescue
    if SSLEnabled and $!.is_a?(OpenSSL::SSL::SSLError)
      raise KeepAliveDisconnected.new
    elsif $!.is_a?(TimeoutError)
      close
      raise
    else
      raise
    end
  end

  @state = :META if @state == :WAIT
  @next_connection = nil
  @requests.push(req)
end