prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  /files/ only serving attachments
  https://github.com/ipython/ipython/pull/6624 changes the behavior of serving html files from '/files/'.
  Instead of displaying a html page, I get the option to download it as file.
  
  Before I got as a response:
  
  ``` Python
  import requests
  r = requests.get('http://localhost:8888/files/Untitled10.html')
  print(r.headers)
  
  {'Last-Modified': 'Sat, 23 Aug 2014 16:03:02 GMT', 
  'Set-Cookie': 'username-localhost-8888=; expires=Thu, 31 Oct 2013 22:14:47 GMT; Path=/',
  'Content-Type': 'text/html', 'X-Frame-Options': 'SAMEORIGIN', 
  'Server': 'TornadoServer/4.0.2', 'Date': 'Fri, 31 Oct 2014 22:14:47 GMT', 
  'Content-Length': '237903', 'Accept-Ranges': 'bytes'}
  ```
  
  Now I get
  
  ``` Python
  r = requests.get('http://localhost:8888/files/Untitled10.html')
  print(r.headers)
  
  {'Date': 'Fri, 31 Oct 2014 22:17:27 GMT', 
  'Transfer-Encoding': 'chunked', 'X-Frame-Options': 'SAMEORIGIN', 
  'Set-Cookie': 'username-localhost-8888=; expires=Thu, 31 Oct 2013 22:17:27 GMT; Path=/',
   'Server': 'TornadoServer/4.0.2', 'Content-Type': 'text/html', 
  'Content-Disposition': 'attachment; filename="Untitled10.html"'}
  ```
  
  Is this an intended new behavior ?
  
  
  </issue>
  <code>
  [start of IPython/html/files/handlers.py]
  1 """Serve files directly from the ContentsManager."""
  2 
  3 # Copyright (c) IPython Development Team.
  4 # Distributed under the terms of the Modified BSD License.
  5 
  6 import os
  7 import mimetypes
  8 import json
  9 import base64
  10 
  11 from tornado import web
  12 
  13 from IPython.html.base.handlers import IPythonHandler
  14 
  15 class FilesHandler(IPythonHandler):
  16     """serve files via ContentsManager"""
  17 
  18     @web.authenticated
  19     def get(self, path):
  20         cm = self.settings['contents_manager']
  21         if cm.is_hidden(path):
  22             self.log.info("Refusing to serve hidden file, via 404 Error")
  23             raise web.HTTPError(404)
  24 
  25         path, name = os.path.split(path)
  26         model = cm.get_model(name, path)
  27 
  28         if model['type'] == 'notebook':
  29             self.set_header('Content-Type', 'application/json')
  30         else:
  31             cur_mime = mimetypes.guess_type(name)[0]
  32             if cur_mime is not None:
  33                 self.set_header('Content-Type', cur_mime)
  34         
  35         self.set_header('Content-Disposition','attachment; filename="%s"' % name)
  36 
  37         if model['format'] == 'base64':
  38             b64_bytes = model['content'].encode('ascii')
  39             self.write(base64.decodestring(b64_bytes))
  40         elif model['format'] == 'json':
  41             self.write(json.dumps(model['content']))
  42         else:
  43             self.write(model['content'])
  44         self.flush()
  45 
  46 default_handlers = [
  47     (r"/files/(.*)", FilesHandler),
  48 ]
  [end of IPython/html/files/handlers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/IPython/html/files/handlers.py b/IPython/html/files/handlers.py
  --- a/IPython/html/files/handlers.py
  +++ b/IPython/html/files/handlers.py
  @@ -24,7 +24,10 @@
   
           path, name = os.path.split(path)
           model = cm.get_model(name, path)
  -
  +        
  +        if self.get_argument("download", False):
  +            self.set_header('Content-Disposition','attachment; filename="%s"' % name)
  +        
           if model['type'] == 'notebook':
               self.set_header('Content-Type', 'application/json')
           else:
  @@ -32,8 +35,6 @@
               if cur_mime is not None:
                   self.set_header('Content-Type', cur_mime)
           
  -        self.set_header('Content-Disposition','attachment; filename="%s"' % name)
  -
           if model['format'] == 'base64':
               b64_bytes = model['content'].encode('ascii')
               self.write(base64.decodestring(b64_bytes))
  
verification_info: {"golden_diff": "diff --git a/IPython/html/files/handlers.py b/IPython/html/files/handlers.py\n--- a/IPython/html/files/handlers.py\n+++ b/IPython/html/files/handlers.py\n@@ -24,7 +24,10 @@\n \n         path, name = os.path.split(path)\n         model = cm.get_model(name, path)\n-\n+        \n+        if self.get_argument(\"download\", False):\n+            self.set_header('Content-Disposition','attachment; filename=\"%s\"' % name)\n+        \n         if model['type'] == 'notebook':\n             self.set_header('Content-Type', 'application/json')\n         else:\n@@ -32,8 +35,6 @@\n             if cur_mime is not None:\n                 self.set_header('Content-Type', cur_mime)\n         \n-        self.set_header('Content-Disposition','attachment; filename=\"%s\"' % name)\n-\n         if model['format'] == 'base64':\n             b64_bytes = model['content'].encode('ascii')\n             self.write(base64.decodestring(b64_bytes))\n", "issue": "/files/ only serving attachments\nhttps://github.com/ipython/ipython/pull/6624 changes the behavior of serving html files from '/files/'.\nInstead of displaying a html page, I get the option to download it as file.\n\nBefore I got as a response:\n\n``` Python\nimport requests\nr = requests.get('http://localhost:8888/files/Untitled10.html')\nprint(r.headers)\n\n{'Last-Modified': 'Sat, 23 Aug 2014 16:03:02 GMT', \n'Set-Cookie': 'username-localhost-8888=; expires=Thu, 31 Oct 2013 22:14:47 GMT; Path=/',\n'Content-Type': 'text/html', 'X-Frame-Options': 'SAMEORIGIN', \n'Server': 'TornadoServer/4.0.2', 'Date': 'Fri, 31 Oct 2014 22:14:47 GMT', \n'Content-Length': '237903', 'Accept-Ranges': 'bytes'}\n```\n\nNow I get\n\n``` Python\nr = requests.get('http://localhost:8888/files/Untitled10.html')\nprint(r.headers)\n\n{'Date': 'Fri, 31 Oct 2014 22:17:27 GMT', \n'Transfer-Encoding': 'chunked', 'X-Frame-Options': 'SAMEORIGIN', \n'Set-Cookie': 'username-localhost-8888=; expires=Thu, 31 Oct 2013 22:17:27 GMT; Path=/',\n 'Server': 'TornadoServer/4.0.2', 'Content-Type': 'text/html', \n'Content-Disposition': 'attachment; filename=\"Untitled10.html\"'}\n```\n\nIs this an intended new behavior ?\n\n", "before_files": [{"content": "\"\"\"Serve files directly from the ContentsManager.\"\"\"\n\n# Copyright (c) IPython Development Team.\n# Distributed under the terms of the Modified BSD License.\n\nimport os\nimport mimetypes\nimport json\nimport base64\n\nfrom tornado import web\n\nfrom IPython.html.base.handlers import IPythonHandler\n\nclass FilesHandler(IPythonHandler):\n    \"\"\"serve files via ContentsManager\"\"\"\n\n    @web.authenticated\n    def get(self, path):\n        cm = self.settings['contents_manager']\n        if cm.is_hidden(path):\n            self.log.info(\"Refusing to serve hidden file, via 404 Error\")\n            raise web.HTTPError(404)\n\n        path, name = os.path.split(path)\n        model = cm.get_model(name, path)\n\n        if model['type'] == 'notebook':\n            self.set_header('Content-Type', 'application/json')\n        else:\n            cur_mime = mimetypes.guess_type(name)[0]\n            if cur_mime is not None:\n                self.set_header('Content-Type', cur_mime)\n        \n        self.set_header('Content-Disposition','attachment; filename=\"%s\"' % name)\n\n        if model['format'] == 'base64':\n            b64_bytes = model['content'].encode('ascii')\n            self.write(base64.decodestring(b64_bytes))\n        elif model['format'] == 'json':\n            self.write(json.dumps(model['content']))\n        else:\n            self.write(model['content'])\n        self.flush()\n\ndefault_handlers = [\n    (r\"/files/(.*)\", FilesHandler),\n]", "path": "IPython/html/files/handlers.py"}]}