| 76 | |
| 77 | |
| 78 | function estimateTypeByHeaderContentType(documentUrl, cb) { |
| 79 | var xhr = new XMLHttpRequest(); |
| 80 | xhr.onreadystatechange = function() { |
| 81 | var mimetype, matchingPluginData; |
| 82 | if (xhr.readyState === 4) { |
| 83 | if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) { |
| 84 | mimetype = xhr.getResponseHeader('content-type'); |
| 85 | |
| 86 | if (mimetype) { |
| 87 | pluginRegistry.some(function(pluginData) { |
| 88 | if (pluginData.supportsMimetype(mimetype)) { |
| 89 | matchingPluginData = pluginData; |
| 90 | console.log('Found plugin by mimetype and xhr head: ' + mimetype); |
| 91 | return true; |
| 92 | } |
| 93 | return false; |
| 94 | }); |
| 95 | } |
| 96 | } |
| 97 | cb(matchingPluginData); |
| 98 | } |
| 99 | }; |
| 100 | xhr.open("HEAD", documentUrl, true); |
| 101 | xhr.send(); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | function doEstimateTypeByFileExtension(extension) { |