@@ -63,7 +63,7 @@ def get(uri, &block)
6363 cached_file , downloaded = from_immutable_caches ( uri ) , false unless cached_file
6464
6565 fail "Unable to find cached file for #{ uri } " unless cached_file
66- cached_file . cached ( File ::RDONLY , downloaded , &block )
66+ cached_file . cached ( File ::RDONLY | File :: BINARY , downloaded , &block )
6767 end
6868
6969 # Removes an item from the mutable cache.
@@ -135,7 +135,7 @@ def attempt(http, request, cached_file)
135135 end
136136
137137 def cache_content ( response , cached_file )
138- cached_file . cached ( File ::CREAT | File ::WRONLY ) do |f |
138+ cached_file . cached ( File ::CREAT | File ::WRONLY | File :: BINARY ) do |f |
139139 @logger . debug { "Persisting content to #{ f . path } " }
140140
141141 f . truncate ( 0 )
@@ -153,7 +153,7 @@ def cache_etag(response, cached_file)
153153
154154 @logger . debug { "Persisting etag: #{ etag } " }
155155
156- cached_file . etag ( File ::CREAT | File ::WRONLY ) do |f |
156+ cached_file . etag ( File ::CREAT | File ::WRONLY | File :: BINARY ) do |f |
157157 f . truncate ( 0 )
158158 f . write etag
159159 f . fsync
@@ -167,7 +167,7 @@ def cache_last_modified(response, cached_file)
167167
168168 @logger . debug { "Persisting last-modified: #{ last_modified } " }
169169
170- cached_file . last_modified ( File ::CREAT | File ::WRONLY ) do |f |
170+ cached_file . last_modified ( File ::CREAT | File ::WRONLY | File :: BINARY ) do |f |
171171 f . truncate ( 0 )
172172 f . write last_modified
173173 f . fsync
@@ -223,11 +223,11 @@ def request(uri, cached_file)
223223 request = Net ::HTTP ::Get . new ( uri . request_uri )
224224
225225 if cached_file . etag?
226- cached_file . etag ( File ::RDONLY ) { |f | request [ 'If-None-Match' ] = File . read ( f ) }
226+ cached_file . etag ( File ::RDONLY | File :: BINARY ) { |f | request [ 'If-None-Match' ] = File . read ( f ) }
227227 end
228228
229229 if cached_file . last_modified?
230- cached_file . last_modified ( File ::RDONLY ) { |f | request [ 'If-Modified-Since' ] = File . read ( f ) }
230+ cached_file . last_modified ( File ::RDONLY | File :: BINARY ) { |f | request [ 'If-Modified-Since' ] = File . read ( f ) }
231231 end
232232
233233 @logger . debug { "Request: #{ request . path } , #{ request . to_hash } " }
0 commit comments