HTTP::Request

class HTTP::Request

Overview

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.

Defined in:

http/request.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.from_io(io)Source

Returns a HTTP::Request instance if successfully parsed, returns nil on EOF, or returns BadRequest.

def self.new(method : String, resource : String, headers : Headers? = nil, body : String | Bytes | IO | Nil = nil, version = "HTTP/1.1")Source

Instance Method Detail

def body : IO?Source

def body=(body : Nil)Source

def body=(body : IO)Source

def body=(body : Bytes)Source

def body=(body : String)Source

def content_lengthSource

def content_length=(length : Int)Source

def cookiesSource

Returns a convenience wrapper around querying and setting cookie related headers, see HTTP::Cookies.

def headers : HeadersSource

def headers=(headers : Headers)Source

def hostSource

Return request host from headers.

def host_with_portSource

Return request host with port from headers.

def ignore_body?Source

def keep_alive?Source

def method : StringSource

def method=(method : String)Source

def pathSource

Lazily parses and return the request's path component.

def path=(path)Source

Sets request's path component.

def querySource

Lazily parses and returns the request's query component.

def query=(value)Source

Sets request's query component.

def query_paramsSource

Returns a convenience wrapper around querying and setting query params, see HTTP::Params.

def resourceSource

def to_io(io)Source

def version : StringSource

def version=(version : String)Source

© 2012–2017 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.22.0/HTTP/Request.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部