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
|
||||
|
||||
class NotModified < Exception
|
||||
ErrorMessage = 'NotModified'
|
||||
end
|
||||
|
||||
# Authorization is required to access the resource specified.
|
||||
class Unauthorized < ExceptionWithResponse
|
||||
ErrorMessage = 'Unauthorized'
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue