Last active
December 25, 2019 01:54
-
-
Save lwzm/7125089ad3b74fbddf6a0774c843e163 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
dd if=/dev/zero bs=1M count=1000 | curl -T - localhost:1111 | |
curl -T /dev/urandom localhost:1111 |
This file contains hidden or 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 python3 | |
import collections | |
import time | |
import json | |
from tornado.web import stream_request_body, Application, RequestHandler | |
@stream_request_body | |
class Handler(RequestHandler): | |
def data_received(self, chunk): | |
(len(chunk)) | |
async def data_received(self, chunk): | |
await asyncio.sleep(1) | |
print(len(chunk)) | |
def put(self): | |
print(self.request) | |
async def get(self): | |
for _ in range(1000 * 1000): | |
self.write(b'x' * 1024) | |
self.flush() | |
await asyncio.sleep(0) | |
@stream_request_body | |
class Handler(RequestHandler): | |
def prepare(self): | |
print(self.request.method) | |
self.tmp = tempfile.NamedTemporaryFile() | |
def on_connection_close(self): | |
self.tmp.close() | |
self.finish() | |
def data_received(self, chunk): | |
self.tmp.write(chunk) | |
def put(self): | |
print(self.tmp.tell()) | |
self.tmp.flush() | |
with open(self.tmp.name, 'ab') as f: | |
print(f.tell()) | |
print(self.request) | |
get = put | |
app = Application([ | |
(r"/.*", Handler), | |
]) | |
if __name__ == '__main__': | |
from tornado.options import define, parse_command_line, options | |
define("port", default=1111) | |
parse_command_line() | |
app.listen(options.port, xheaders=True, max_buffer_size=float('inf')) | |
from tornado.ioloop import IOLoop | |
IOLoop.current().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment