lib/carrierwave/downloader/base.rb
def download(url, remote_headers = {})
        @current_download_retry_count = 0
        headers = remote_headers.
          reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")
        uri = process_uri(url.to_s)
        begin
          if skip_ssrf_protection?(uri)
            response = OpenURI.open_uri(process_uri(url.to_s), headers)
          else
            request = nil
            response = SsrfFilter.get(uri, headers: headers) do |req|
              request = req
            end
            response.uri = request.uri
            response.value
          end
        rescue StandardError => e
          if @current_download_retry_count < @uploader.download_retry_count
            @current_download_retry_count += 1
            sleep 5
            retry
          else
            raise CarrierWave::DownloadError, "could not download file: #{e.message}"
          end
        end
        CarrierWave::Downloader::RemoteFile.new(response)
      end
##
# Downloads a file from given URL and returns a RemoteFile.
#
# === Parameters
#
# [url (String)] The URL where the remote file is stored
# [remote_headers (Hash)] Request headers
#
Downloads a file from given URL and returns a RemoteFile.
Parameters

[url (String)] The URL where the remote file is stored
[remote_headers (Hash)] Request headers
Downloads a file from given URL and returns a RemoteFile . Parameters [ url ( String ) ] The URL where the remote file is stored [ remote_headers ( Hash ) ] Request headers
def download(url, remote_headers = {})
        @current_download_retry_count = 0
        headers = remote_headers.
          reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")
        uri = process_uri(url.to_s)
        begin
          if skip_ssrf_protection?(uri)
            response = OpenURI.open_uri(process_uri(url.to_s), headers)
          else
            request = nil
            response = SsrfFilter.get(uri, headers: headers) do |req|
              request = req
            end
            response.uri = request.uri
            response.value
          end
        rescue StandardError => e
          if @current_download_retry_count < @uploader.download_retry_count
            @current_download_retry_count += 1
            sleep 5
            retry
          else
            raise CarrierWave::DownloadError, "could not download file: #{e.message}"
          end
        end
        CarrierWave::Downloader::RemoteFile.new(response)
      end
def download ( url , remote_headers = { } ) @current_download_retry_count = 0 headers = remote_headers . reverse_merge ( 'User-Agent' => "CarrierWave/#{CarrierWave::VERSION}" ) uri = process_uri ( url . to_s ) begin if skip_ssrf_protection? ( uri ) response = OpenURI . open_uri ( process_uri ( url . to_s ) , headers ) else request = nil response = SsrfFilter . get ( uri , headers : headers ) do | req | request = req end response . uri = request . uri response . value end rescue StandardError => e if @current_download_retry_count < @uploader . download_retry_count @current_download_retry_count += 1 sleep 5 retry else raise CarrierWave :: DownloadError , "could not download file: #{e.message}" end end CarrierWave :: Downloader :: RemoteFile . new ( response ) end
Downloads a file from given URL and returns a RemoteFile.
Downloads a file from given URL and returns a RemoteFile .
url
remote_headers