Class: Kudzu::Agent::Util::MimeTypeDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/kudzu/agent/util/mime_type_detector.rb

Constant Summary collapse

DEFALUT_MIME_TYPE =
'application/octet-stream'

Class Method Summary collapse

Class Method Details

.detect(response) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/kudzu/agent/util/mime_type_detector.rb', line 8

def detect(response)
  from_header(response.response_header) ||
    from_body(response.body) ||
    from_url(response.url) ||
    DEFALUT_MIME_TYPE
rescue => e
  Kudzu.log :warn, "failed to detect mime: #{response.url}", error: e
  nil
end