class SF::Http::Request
- SF::Http::Request
- Reference
- Object
Overview
Define a HTTP request
Defined in:
network/obj.crConstructors
-
.new(uri : String = "/", method : Http::Request::Method = Get, body : String = "")
Default constructor
Instance Method Summary
-
#body=(body : String)
Set the body of the request
-
#dup : Request
Returns a shallow copy of this object.
- #finalize
-
#method=(method : Http::Request::Method)
Set the request method
-
#set_field(field : String, value : String)
Set the value of a field
-
#set_http_version(major : Int, minor : Int)
Set the HTTP version for the request
-
#uri=(uri : String)
Set the requested URI
Constructor Detail
Default constructor
This constructor creates a GET request, with the root URI ("/") and an empty body.
- uri - Target URI
- method - Method to use for the request
- body - Content of the request's body
Instance Method Detail
Set the body of the request
The body of a request is optional and only makes sense for POST requests. It is ignored for all other methods. The body is empty by default.
- body - Content of the body
Returns a shallow copy of this object.
This allocates a new object and copies the contents of
self
into it.
Set the request method
See the Method enumeration for a complete list of all the availale methods. The method is Http::Request::Get by default.
- method - Method to use for the request
Set the value of a field
The field is created if it doesn't exist. The name of the field is case-insensitive. By default, a request doesn't contain any field (but the mandatory fields are added later by the HTTP client when sending the request).
- field - Name of the field to set
- value - Value of the field
Set the HTTP version for the request
The HTTP version is 1.0 by default.
- major - Major HTTP version number
- minor - Minor HTTP version number
Set the requested URI
The URI is the resource (usually a web page or a file) that you want to get or post. The URI is "/" (the root page) by default.
- uri - URI to request, relative to the host