Skip to content

Instantly share code, notes, and snippets.

@nicr9
Last active December 24, 2023 07:32
Show Gist options
  • Save nicr9/d3d0a96f39c4ac7956dfad74b5b411c6 to your computer and use it in GitHub Desktop.
Save nicr9/d3d0a96f39c4ac7956dfad74b5b411c6 to your computer and use it in GitHub Desktop.
Add `Content-Disposition` header to SimpleHttpServer
#!/usr/bin/env python
from SimpleHTTPServer import SimpleHTTPRequestHandler, test
class CustomRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.add_content_disposition()
SimpleHTTPRequestHandler.end_headers(self)
def add_content_disposition(self):
self.send_header("Content-Disposition", 'filename="content_disposition.py"')
if __name__ == '__main__':
test(HandlerClass=CustomRequestHandler)
@cooliscool
Copy link

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment