parameters: (headers, content)
return_statement: return list(headers)
docstring: Return new headers based on `headers` but with `Content-Length` and
      `Content-Type` set appropriately depending on the given `content` only if it
      is safe to do, as well as `X-Content-Type-Options: nosniff` so that if the
      file is of an unsafe type, it is not interpreted as that type if the
      `Content-type` header was already set to a different mimetype
docstring_summary: Return new headers based on `headers` but with `Content-Length` and
      `Content-Type` set appropriately depending on the given `content` only if it
      is safe to do, as well as `X-Content-Type-Options: nosniff` so that if the
      file is of an unsafe type, it is not interpreted as that type if the
      `Content-type` header was already set to a different mimetype
docstring_tokens: Return new headers based on headers but with Content - Length and Content - Type set appropriately depending on the given content only if it is safe to do as well as X - Content - Type - Options : nosniff so that if the file is of an unsafe type it is not interpreted as that type if the Content - type header was already set to a different mimetype
function: def set_safe_image_headers(headers, content):
      """Return new headers based on `headers` but with `Content-Length` and
      `Content-Type` set appropriately depending on the given `content` only if it
      is safe to do, as well as `X-Content-Type-Options: nosniff` so that if the
      file is of an unsafe type, it is not interpreted as that type if the
      `Content-type` header was already set to a different mimetype
      """
      headers = werkzeug.datastructures.Headers(headers)
      safe_types = {'image/jpeg', 'image/png', 'image/gif', 'image/x-icon'}
      content_type = guess_mimetype(content)
      if content_type in safe_types:
          headers['Content-Type'] = content_type
      headers['X-Content-Type-Options'] = 'nosniff'
      headers['Content-Length'] = len(content)
      return list(headers)
function_tokens: def set_safe_image_headers ( headers , content ) : headers = werkzeug . datastructures . Headers ( headers ) safe_types = { 'image/jpeg' , 'image/png' , 'image/gif' , 'image/x-icon' } content_type = guess_mimetype ( content ) if content_type in safe_types : headers [ 'Content-Type' ] = content_type headers [ 'X-Content-Type-Options' ] = 'nosniff' headers [ 'Content-Length' ] = len ( content ) return list ( headers )