module HTTP

Overview

The HTTP module contains HTTP::Client, HTTP::Server and HTTP::WebSocket implementations.

Defined in:

http/client.cr
http/common.cr
http/params.cr
http/content.cr
http/cookie.cr
http.cr

Class Method Summary

Class Method Detail

def self.default_status_message_for(status_code : Int) : String #

Returns the default status message of the given HTTP status code.

Based on Hypertext Transfer Protocol (HTTP) Status Code Registry

Last Updated 2017-04-14

HTTP Status Codes (source: http-status-codes-1.csv)

  • 1xx: Informational - Request received, continuing process
  • 2xx: Success - The action was successfully received, understood, and accepted
  • 3xx: Redirection - Further action must be taken in order to complete the request
  • 4xx: Client Error - The request contains bad syntax or cannot be fulfilled
  • 5xx: Server Error - The server failed to fulfill an apparently valid request

View source
def self.dequote_string(str) #

Dequotes an RFC 2616 quoted-string.

quoted = %q(\"foo\\bar\")
HTTP.dequote_string(quoted) # => %q("foo\bar")

View source
def self.parse_time(time_str : String) : Time? #

View source
def self.quote_string(string, io) #

Encodes a string to an RFC 2616 quoted-string. Encoded string is written to io. May raise when string contains an invalid character.

string = %q("foo\ bar")
io = IO::Memory.new
HTTP.quote_string(string, io)
io.gets_to_end # => %q(\"foo\\\ bar\")

View source
def self.quote_string(string) #

Encodes a string to an RFC 2616 quoted-string. May raise when string contains an invalid character.

string = %q("foo\ bar")
HTTP.quote_string(string) # => %q(\"foo\\\ bar\")

View source
def self.rfc1123_date(time : Time) : String #

Format a Time object as a String using the format specified by RFC 1123.

HTTP.rfc1123_date(Time.new(2016, 2, 15)) # => "Sun, 14 Feb 2016 21:00:00 GMT"

View source
def self.serialize_chunked_body(io, body) #

View source
def self.serialize_headers(io, headers) #

View source
def self.serialize_headers_and_string_body(io, headers, body) #

View source