class LinkHeader

Defined in:

link-header.cr

Constant Summary

ATTR = /#{TOKEN} *= *(#{TOKEN}|#{QUOTED}) */
COMMA = /, */
HREF = /\ *< *([^>]*) *> *;? */

Regexes for link header parsing. TOKEN and QUOTED in particular should conform to RFC2616.

Acknowledgement: The QUOTED regexp is based on http://stackoverflow.com/questions/249791/regexp-for-quoted-string-with-escaping-quotes/249937#249937

QUOTED = /"((?:[^"\\]|\\.)*)"/
SEMI = /; */
TOKEN = /([^()<>@,;:\"\[\]?={}\s]+)/

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(links : Hash(String, Hash(String, String))) #

[View source]
def self.new(link_header : String) #

[View source]
def self.new(headers : HTTP::Headers) #

[View source]
def self.new(response : HTTP::Client::Response) #

[View source]
def self.new #

[View source]

Class Method Detail

def self.parse(headers : HTTP::Headers) : Hash(String, Hash(String, String)) #

[View source]
def self.parse(link_header : String) : Hash(String, Hash(String, String)) #

[View source]

Instance Method Detail

def [](key : String) : String #

shortcut for looking up links matching rel


[View source]
def []?(key : String) : String | Nil #

[View source]
def add(link : String, keys : Hash(String, String)) #

[View source]
def fetch(key : String, &) #

[View source]
def fetch(key : String, default) #

[View source]
def get(key : String) #

[View source]
def links : Hash(String, Hash(String, String)) #

[View source]
def to_s(io : IO) : Nil #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

[View source]