Class: Concuss::Headers

Inherits:
Object
  • Object
show all
Defined in:
lib/concuss/headers.rb

Constant Summary collapse

STANDARD_HEADERS =
[
  'Accept',
  'Accept-Charset',
  'Accept-Encoding',
  'Accept-Language',
  'Accept-Datetime',
  'Authorization',
  'Cache-Control',
  'Connection',
  'Cookie',
  'Content-Length',
  'Content-MD5',
  'Content-Type',
  'Date',
  'Expect',
  'From',
  'Host',
  'If-Match',
  'If-Modified-Since',
  'If-None-Match',
  'If-Range',
  'If-Unmodified-Since',
  'Max-Forwards',
  'Origin',
  'Pragma',
  'Proxy-Authorization',
  'Range',
  'Referer',
  'TE',
  'User-Agent',
  'Upgrade',
  'Via',
  'Warning'
]
NON_STANDARD_HEADERS =
[
  'X-Requested-With',
  'X-Forwarded-For',
  'X-Forwarded-Proto',
  'X-Http-Method-Override',
  'X-CSRF-Token'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header_set:, file: nil) ⇒ Headers

Returns a new instance of Headers.



47
48
49
50
# File 'lib/concuss/headers.rb', line 47

def initialize(header_set:, file: nil)
  @header_set = header_set
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



2
3
4
# File 'lib/concuss/headers.rb', line 2

def file
  @file
end

#header_setObject (readonly)

Returns the value of attribute header_set.



2
3
4
# File 'lib/concuss/headers.rb', line 2

def header_set
  @header_set
end

Instance Method Details

#groupObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/concuss/headers.rb', line 52

def group
  case @header_set
  when :standard
    STANDARD_HEADERS
  when :non_standard
    NON_STANDARD_HEADERS
  when :all
    STANDARD_HEADERS + NON_STANDARD_HEADERS
  when :file
    read_file(@file)
  else
    fail "Invalid header set"
  end
end