Method: FTW::Agent#request
- Defined in:
- lib/ftw/agent.rb
#request(method, uri, options) ⇒ Object
Build a request. Returns a FTW::Request object.
Arguments:
-
method - the http method
-
uri - the URI to make the request to
-
options - a hash of options
uri can be a valid url or an Addressable::URI object. The uri will be used to choose the host/port to connect to. It also sets the protocol (https, etc). Further, it will set the ‘Host’ header.
The ‘options’ hash supports the following keys:
-
:headers => { string => string, … }. This allows you to set header values.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/ftw/agent.rb', line 249 def request(method, uri, ) @logger.info("Creating new request", :method => method, :uri => uri, :options => ) request = FTW::Request.new(uri) request.method = method request.headers.add("Connection", "keep-alive") if .include?(:headers) [:headers].each do |key, value| request.headers.add(key, value) end end if .include?(:body) request.body = [:body] end return request end |