module Patron::ResponseDecoding
def decode_header_data(str)
def decode_header_data(str) # Header data is tricky. Strictly speaking, it _must_ be ISO-encoded. However, Content-Disposition # sometimes gets sent as raw UTF8 - and most browsers (except for localized IE versions on Windows) # treat it as such. So a fallback chain of 8859-1->UTF8->binary seems the most sane. tries = [Encoding::ISO8859_1, Encoding::UTF_8, Encoding::BINARY] tries.each do |possible_enc| begin return str.encode(possible_enc) rescue ::Encoding::UndefinedConversionError next end end str # if it doesn't encode, just give back what we got end