I have a simple HTTP server having a do_POST method for uploading image file.
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
data = self.rfile.readlines()
Its taking long time for reading the image binary data. How can I make it read the image data faster.
Found solution for reading whole incoming binary data.
data = self.rfile.read(int(self.headers['Content-Length']))
Where Content-Length entity-header field indicates the size of the entity-body, (Note: remember to convert the content-length
type into int
before passing it into read()
)