bin/httphere in httphere-1.1.1 vs bin/httphere in httphere-1.1.2

- old
+ new

@@ -615,11 +615,11 @@ def process # Get the filename desired filename, query = resource_uri.split('?',2) @filename = filename.sub(/^\//,'') # Default to any file named index.* - @filename = Dir["index.*"].first if filename.to_s == '' && Dir["index.*"].length > 0 + @filename = Dir["index.*"].first if @filename.to_s == '' && Dir["index.*"].length > 0 file_extension = (filename.match(/\.([^\.]+)$/) || [])[1] if File.exists?(@filename) && !File.directory?(@filename) # Read from cache if possible @@ -666,11 +666,11 @@ body, content_type = FileServer.from_cache(@filename) else body = StringIO.new(body.to_s) if !body.is_a?(IO) && body.respond_to?(:to_s) # Convert to UTF-8 if possible - chardet = UniversalDetector::chardet(body.read(512)); body.rewind # Detect charset only from the first 512 bytes - if chardet['confidence'] > 0.7 && ['utf-8', 'ascii'].include?(chardet['encoding']) + chardet = UniversalDetector::chardet(body.read(512)) rescue {'confidence' => 0.8, 'encoding' => 'utf-8'}; body.rewind # Detect charset only from the first 512 bytes + if chardet['confidence'] > 0.7 && !['utf-8', 'ascii'].include?(chardet['encoding']) if $DEBUG Benchmark.bm do |x| x.report("Converting from #{chardet['encoding']} to UTF-8") do charset = chardet['encoding'] body = StringIO.new(Iconv.conv('utf-8', charset, body.read))