class

HTTP::Request

Inherits Reference / Object

An HTTP request.

It serves both to perform requests by an HTTP::Client and to represent requests received by an HTTP::Server.

A request always holds an IO as a body. When creating a request with a String or Bytes its body will be a IO::Memory wrapping these, and the Content-Length header will be set appropriately.

NOTE: To use Request, you must explicitly import it with require "http/request"

Constructors

new(method : String, resource : String, headers : Headers | Nil = nil, body : String | Bytes | IO | Nil = nil, expect_continue : Bool = false, version = "HTTP/1.1")
Source
new(method : String, resource : String, headers : Headers | Nil = nil, body : String | Bytes | IO | Nil = nil, version = "HTTP/1.1")
Source

Class methods

get_host_from_text(text : String)
Source
get_port_from_text(text : String) : Int32 | Nil
Source
parse_port(text : String)
Source

Instance methods

body=(body : Nil)
Source
compress_type
Source
connect?
Source
connect_host
Source
connect_port
Source
content_length
Source
encoding?
Source
header_host
Source
header_host=(value : String)
Source
header_keep_alive=(value : Bool)
Source
header_port
Source
regular_port
Source
serialize_headers_and_body(io)
Source
to_io(io, without_body : Bool)
Source