string_response string, status, content_type: nil

in lib/functions_framework/server.rb [418:432]


      def string_response string, status, content_type: nil
        string.force_encoding ::Encoding::ASCII_8BIT unless string.valid_encoding?
        if string.encoding == ::Encoding::ASCII_8BIT
          content_type ||= "application/octet-stream"
        else
          content_type ||= "text/plain"
          content_type = "#{content_type}; charset=#{string.encoding.name.downcase}"
        end
        headers = {
          "content-type"   => content_type,
          "content-length" => string.bytesize
        }
        [status, headers, [string]]
      end