mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
add '304 Not Modified' support
This commit is contained in:
parent
5181306f23
commit
f0b2e44885
2 changed files with 7 additions and 1 deletions
|
@ -30,6 +30,10 @@ module RestClient
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class NotModified < Exception
|
||||||
|
ErrorMessage = 'NotModified'
|
||||||
|
end
|
||||||
|
|
||||||
# Authorization is required to access the resource specified.
|
# Authorization is required to access the resource specified.
|
||||||
class Unauthorized < ExceptionWithResponse
|
class Unauthorized < ExceptionWithResponse
|
||||||
ErrorMessage = 'Unauthorized'
|
ErrorMessage = 'Unauthorized'
|
||||||
|
|
|
@ -202,6 +202,8 @@ module RestClient
|
||||||
end
|
end
|
||||||
|
|
||||||
raise Redirect, url
|
raise Redirect, url
|
||||||
|
elsif res.code == "304"
|
||||||
|
raise NotModified
|
||||||
elsif res.code == "401"
|
elsif res.code == "401"
|
||||||
raise Unauthorized, res
|
raise Unauthorized, res
|
||||||
elsif res.code == "404"
|
elsif res.code == "404"
|
||||||
|
@ -230,7 +232,7 @@ module RestClient
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_log(res)
|
def response_log(res)
|
||||||
"# => #{res.code} #{res.class.to_s.gsub(/^Net::HTTP/, '')} | #{(res['Content-type'] || '').gsub(/;.*$/, '')} #{res.body.size} bytes"
|
"# => #{res.code} #{res.class.to_s.gsub(/^Net::HTTP/, '')} | #{(res['Content-type'] || '').gsub(/;.*$/, '')} #{(res.body) ? res.body.size : nil} bytes"
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_log(msg)
|
def display_log(msg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue