class Google::APIClient::Charset

Public Instance Methods

adjust_encoding(env) click to toggle source
# File lib/google/api_client/charset.rb, line 19
def adjust_encoding(env)
  charset = charset_for_content_type(env[:response_headers]['content-type'])
  if charset && env[:body].encoding != charset
    env[:body].force_encoding(charset)
  end
end
charset_for_content_type(type) click to toggle source
# File lib/google/api_client/charset.rb, line 9
def charset_for_content_type(type)
  if type
    m = type.match(/(?:charset|encoding)="?([a-z0-9-]+)"?/)
    if m
      return Encoding.find(m[1])
    end
  end
  nil
end
on_complete(env) click to toggle source
# File lib/google/api_client/charset.rb, line 26
def on_complete(env)
  adjust_encoding(env)
end