File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
bindings/ruby/lib/whisper Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,8 @@ def initialize(uri)
1111 end
1212
1313 def to_path
14- path = cache_path
15- return path . to_path if cache_path . exist?
16-
1714 cache
18- path . to_path
15+ cache_path . to_path
1916 end
2017
2118 def clear_cache
@@ -42,14 +39,20 @@ def base_cache_dir
4239 end
4340
4441 def cache
45- request @uri
42+ path = cache_path
43+ headers = { }
44+ headers [ "if-modified-since" ] = path . mtime . httpdate if path . exist?
45+ request @uri , headers
46+ path
4647 end
4748
48- def request ( uri )
49+ def request ( uri , headers )
4950 Net ::HTTP . start uri . host , uri . port , use_ssl : uri . scheme == "https" do |http |
50- request = Net ::HTTP ::Get . new ( uri )
51+ request = Net ::HTTP ::Get . new ( uri , headers )
5152 http . request request do |response |
5253 case response
54+ when Net ::HTTPNotModified
55+ # noop
5356 when Net ::HTTPOK
5457 download response
5558 when Net ::HTTPRedirection
You can’t perform that action at this time.
0 commit comments