Class: Async::HTTP::Response

Inherits:
Struct
  • Object
show all
Includes:
Body::Buffered::Reader
Defined in:
lib/async/http/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Body::Buffered::Reader

#finish, #read

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



25
26
27
# File 'lib/async/http/response.rb', line 25

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



25
26
27
# File 'lib/async/http/response.rb', line 25

def headers
  @headers
end

#reasonObject

Returns the value of attribute reason

Returns:

  • (Object)

    the current value of reason



25
26
27
# File 'lib/async/http/response.rb', line 25

def reason
  @reason
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



25
26
27
# File 'lib/async/http/response.rb', line 25

def status
  @status
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



25
26
27
# File 'lib/async/http/response.rb', line 25

def version
  @version
end

Class Method Details

.[](status, headers = {}, body = []) ⇒ Object



48
49
50
51
52
# File 'lib/async/http/response.rb', line 48

def self.[](status, headers = {}, body = [])
  body = Body::Buffered.wrap(body)
  
  self.new(nil, status, nil, headers, body)
end

.for_exception(exception) ⇒ Object



54
55
56
# File 'lib/async/http/response.rb', line 54

def self.for_exception(exception)
  Async::HTTP::Response[500, {'content-type' => 'text/plain'}, ["#{exception.class}: #{exception.message}"]]
end

Instance Method Details

#continue?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/async/http/response.rb', line 28

def continue?
  status == 100
end

#failure?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/async/http/response.rb', line 44

def failure?
  status >= 400 && status < 600
end

#preserve_method?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/async/http/response.rb', line 40

def preserve_method?
  status == 307 || status == 308
end

#redirection?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/async/http/response.rb', line 36

def redirection?
  status >= 300 && status < 400
end

#success?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/async/http/response.rb', line 32

def success?
  status >= 200 && status < 300
end