Python HTTPServer - get HTTP body -


i wrote http server using python, not know how http body. should http body?

here code:

from http.server import httpserver,basehttprequesthandler  class myhttphandler(basehttprequesthandler):     def do_get(self):         print("connect ",self.client_address)         print(self.headers)         length = self.headers['content-length']         print(length)  addr = ('',21567) server = httpserver(addr,myhttphandler) server.serve_forever() 

having request body in request not practice, discussed here: http request body

instead, can change method post , check there basehttprequesthandler documentation: https://docs.python.org/2/library/basehttpserver.html

especially part:

rfile

contains input stream, positioned @ start of optional input data.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -