File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,7 +206,6 @@ def over_ios17?(os_version)
206206 end
207207
208208 # Download the given url content into the file path.
209- # Raises an exception if the given url was invalid.
210209 # @param url URL to the content.
211210 # @param file_path Path to destination to download the given url content.
212211 # @return Path to the downloaded content.
@@ -216,22 +215,18 @@ def download_content(url, file_path)
216215
217216 FileUtils . mkdir_p ( File . dirname ( file_path ) )
218217
219- # Follow redirects (up to 5 times)
220218 MAX_REDIRECT . times do
221219 Net ::HTTP . start ( uri . host , uri . port , use_ssl : uri . scheme == 'https' ) do |http |
222220 http . request ( Net ::HTTP ::Get . new ( uri . request_uri ) ) do |resp |
223- if resp . is_a? ( Net ::HTTPRedirection )
221+ case resp
222+ when Net ::HTTPRedirection
224223 uri = URI . parse ( resp [ 'location' ] )
225- next
224+ when Net ::HTTPSuccess
225+ File . open ( file_path , 'wb' ) { |f | resp . read_body { |chunk | f . write ( chunk ) } }
226+ return file_path
227+ else
228+ raise "Unexpected response: #{ resp . code } "
226229 end
227-
228- raise "Unexpected response: #{ resp . code } " unless resp . is_a? ( Net ::HTTPSuccess )
229-
230- File . open ( file_path , 'wb' ) do |file |
231- resp . read_body { |chunk | file . write ( chunk ) }
232- end
233-
234- return file_path
235230 end
236231 end
237232 end
You can’t perform that action at this time.
0 commit comments