1
0
Fork 0
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:
T.Watanabe 2008-10-14 23:38:13 +09:00 committed by Adam Wiggins
parent 5181306f23
commit f0b2e44885
2 changed files with 7 additions and 1 deletions

View file

@ -30,6 +30,10 @@ module RestClient
end
end
class NotModified < Exception
ErrorMessage = 'NotModified'
end
# Authorization is required to access the resource specified.
class Unauthorized < ExceptionWithResponse
ErrorMessage = 'Unauthorized'

View file

@ -202,6 +202,8 @@ module RestClient
end
raise Redirect, url
elsif res.code == "304"
raise NotModified
elsif res.code == "401"
raise Unauthorized, res
elsif res.code == "404"
@ -230,7 +232,7 @@ module RestClient
end
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
def display_log(msg)