Last active
December 24, 2023 07:32
-
-
Save nicr9/d3d0a96f39c4ac7956dfad74b5b411c6 to your computer and use it in GitHub Desktop.
Add `Content-Disposition` header to SimpleHttpServer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🎉