class SF::Http::Response

Overview

Define a HTTP response

Defined in:

network/obj.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Default constructor

Constructs an empty response.


[View source]

Instance Method Detail

def body : String #

Get the body of the response

The body of a response may contain:

  • the requested page (for GET requests)
  • a response from the server (for POST requests)
  • nothing (for HEAD requests)
  • an error message (in case of an error)

Returns: The response body


[View source]
def dup : Response #
Description copied from class Reference

Returns a shallow copy of this object.

This allocates a new object and copies the contents of self into it.


[View source]
def finalize #

[View source]
def get_field(field : String) : String #

Get the value of a field

If the field field is not found in the response header, the empty string is returned. This function uses case-insensitive comparisons.

  • field - Name of the field to get

Returns: Value of the field, or empty string if not found


[View source]
def major_http_version : Int32 #

Get the major HTTP version number of the response

Returns: Major HTTP version number

See also: #minor_http_version


[View source]
def minor_http_version : Int32 #

Get the minor HTTP version number of the response

Returns: Minor HTTP version number

See also: #major_http_version


[View source]
def status : Http::Response::Status #

Get the response status code

The status code should be the first thing to be checked after receiving a response, it defines whether it is a success, a failure or anything else (see the Status enumeration).

Returns: Status code of the response


[View source]