app/controllers/cms/agents/tasks/links_controller.rb
# Checks the existence with HEAD request.
Checks the existence with HEAD request.
Checks the existence with HEAD request .
def check_head(url)
    http_basic_authentication = SS::MessageEncryptor.http_basic_authentication
    redirection = 0
    max_redirection = SS.config.cms.check_links["max_redirection"].to_i
    if url.match?(/^\/\//)
      url = @base_url.sub(/\/\/.*$/, url)
    elsif url[0] == "/"
      url = File.join(@base_url, url)
    end
    begin
      Timeout.timeout(@head_request_timeout) do
        ::URI.open url, proxy: true, redirect: false, http_basic_authentication: http_basic_authentication, progress_proc: ->(size) { raise "200" }
      end
      false
    rescue OpenURI::HTTPRedirect => e
      return false if redirection >= max_redirection
      redirection += 1
      url = e.uri
      retry
    rescue Timeout::Error
      return false
    rescue => e
      return e.to_s == "200"
    end
  end
def check_head ( url ) http_basic_authentication = SS :: MessageEncryptor . http_basic_authentication redirection = 0 max_redirection = SS . config . cms . check_links [ "max_redirection" ] . to_i if url . match? ( / ^ \/ \/ / ) url = @base_url . sub ( / \/ \/ .*$ / , url ) elsif url [ 0 ] == "/" url = File . join ( @base_url , url ) end begin Timeout . timeout ( @head_request_timeout ) do :: URI . open url , proxy : true , redirect : false , http_basic_authentication : http_basic_authentication , progress_proc : -> ( size ) { raise "200" } end false rescue OpenURI :: HTTPRedirect => e return false if redirection >= max_redirection redirection += 1 url = e . uri retry rescue Timeout :: Error return false rescue => e return e . to_s == "200" end end
Checks the existence with HEAD request.
Checks the existence with HEAD request .
url
<not_specific>