Class: ShamRack::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/sham_rack/http.rb

Overview

a sham version of Net::HTTP

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, port, rack_app) ⇒ HTTP

Returns a new instance of HTTP.



6
7
8
9
10
# File 'lib/sham_rack/http.rb', line 6

def initialize(address, port, rack_app)
  @address = address
  @port = port
  @rack_app = rack_app
end

Instance Attribute Details

#open_timeoutObject

Returns the value of attribute open_timeout.



16
17
18
# File 'lib/sham_rack/http.rb', line 16

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



16
17
18
# File 'lib/sham_rack/http.rb', line 16

def read_timeout
  @read_timeout
end

#use_sslObject

Returns the value of attribute use_ssl.



16
17
18
# File 'lib/sham_rack/http.rb', line 16

def use_ssl
  @use_ssl
end

#verify_modeObject

Returns the value of attribute verify_mode.



16
17
18
# File 'lib/sham_rack/http.rb', line 16

def verify_mode
  @verify_mode
end

Instance Method Details

#request(req, body = nil) {|response| ... } ⇒ Object

Yields:

  • (response)


18
19
20
21
22
23
24
25
26
27
# File 'lib/sham_rack/http.rb', line 18

def request(req, body = nil)
  env = default_env
  env.merge!(path_env(req.path))
  env.merge!(method_env(req))
  env.merge!(header_env(req))
  env.merge!(io_env(req, body))
  response = build_response(@rack_app.call(env))
  yield response if block_given?
  return response
end

#start {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



12
13
14
# File 'lib/sham_rack/http.rb', line 12

def start
  yield self
end