Module: Wrest::HttpCodes

Included in:
Curl::Response, Native::Response
Defined in:
lib/wrest/http_codes.rb

Overview

Contains convenience methods to check HTTP response codes

Instance Method Summary collapse

Instance Method Details

#accepted?Boolean



22
23
24
# File 'lib/wrest/http_codes.rb', line 22

def accepted?
  self.code.to_i == 202
end

#bad_request?Boolean



50
51
52
# File 'lib/wrest/http_codes.rb', line 50

def bad_request?
  self.code.to_i == 400
end

#created?Boolean



18
19
20
# File 'lib/wrest/http_codes.rb', line 18

def created?
  self.code.to_i == 201
end

#forbidden?Boolean



58
59
60
# File 'lib/wrest/http_codes.rb', line 58

def forbidden?
  self.code.to_i == 403
end

#found?Boolean



34
35
36
# File 'lib/wrest/http_codes.rb', line 34

def found?
  self.code.to_i == 302
end

#internal_server_error?Boolean



78
79
80
# File 'lib/wrest/http_codes.rb', line 78

def internal_server_error?
  self.code.to_i == 500
end

#method_not_allowed?Boolean



66
67
68
# File 'lib/wrest/http_codes.rb', line 66

def method_not_allowed?
  self.code.to_i == 405
end

#moved_permanently?Boolean



30
31
32
# File 'lib/wrest/http_codes.rb', line 30

def moved_permanently?
  self.code.to_i == 301
end

#no_content?Boolean



26
27
28
# File 'lib/wrest/http_codes.rb', line 26

def no_content?
  self.code.to_i == 204
end

#not_acceptable?Boolean



70
71
72
# File 'lib/wrest/http_codes.rb', line 70

def not_acceptable?
  self.code.to_i == 406
end

#not_found?Boolean



62
63
64
# File 'lib/wrest/http_codes.rb', line 62

def not_found?
  self.code.to_i == 404
end

#not_modified?Boolean



42
43
44
# File 'lib/wrest/http_codes.rb', line 42

def not_modified?
  self.code.to_i == 304
end

#ok?Boolean



14
15
16
# File 'lib/wrest/http_codes.rb', line 14

def ok?
  self.code.to_i == 200
end

#see_other?Boolean



38
39
40
# File 'lib/wrest/http_codes.rb', line 38

def see_other?
  self.code.to_i == 303
end

#temporary_redirect?Boolean



46
47
48
# File 'lib/wrest/http_codes.rb', line 46

def temporary_redirect?
  self.code.to_i == 307
end

#unauthorized?Boolean



54
55
56
# File 'lib/wrest/http_codes.rb', line 54

def unauthorized?
  self.code.to_i == 401
end

#unprocessable_entity?Boolean



74
75
76
# File 'lib/wrest/http_codes.rb', line 74

def unprocessable_entity?
  self.code.to_i == 422
end