Class: Tzispa::Http::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/tzispa/http/request.rb

Constant Summary collapse

ALLOWED_HTTP_VERSIONS =
['HTTP/1.1', 'HTTP/2.0'].freeze
HTTP_X_FORWARDED_HOST =
'HTTP_X_FORWARDED_HOST'
REQUEST_METHOD =
Rack::REQUEST_METHOD

Instance Method Summary collapse

Instance Method Details

#allowed_http_version?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/tzispa/http/request.rb', line 25

def allowed_http_version?
  ALLOWED_HTTP_VERSIONS.include? http_version
end

#forwarded?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/tzispa/http/request.rb', line 17

def forwarded?
  env.include? HTTP_X_FORWARDED_HOST
end

#http_versionObject



21
22
23
# File 'lib/tzispa/http/request.rb', line 21

def http_version
  env['HTTP_VERSION']
end

#idempotent?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/tzispa/http/request.rb', line 33

def idempotent?
  safe? || put? || delete? || link? || unlink?
end

#link?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/tzispa/http/request.rb', line 37

def link?
  request_method == 'LINK'
end

#safe?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/tzispa/http/request.rb', line 29

def safe?
  get? || head? || options? || trace?
end

#unlink?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/tzispa/http/request.rb', line 41

def unlink?
  request_method == 'UNLINK'
end