daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest May 16th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def do_POST(self):
  2.             '''
  3.            Handle POST requests.
  4.            '''
  5.             logging.debug('POST %s' % (self.path))
  6.  
  7.             # CITATION: http://stackoverflow.com/questions/4233218/python-basehttprequesthandler-post-variables
  8.             ctype, pdict = cgi.parse_header(self.headers['content-type'])
  9.             if ctype == 'multipart/form-data':
  10.                 postvars = cgi.parse_multipart(self.rfile, pdict)
  11.             elif ctype == 'application/x-www-form-urlencoded':
  12.                 length = int(self.headers['content-length'])
  13.                 postvars = cgi.parse_qs(self.rfile.read(length), keep_blank_values=1)
  14.             else:
  15.                 postvars = {}
  16.  
  17.             # Get the "Back" link.
  18.             back = self.path if self.path.find('?') < 0 else self.path[:self.path.find('?')]
  19.  
  20.             # Print out logging information about the path and args.
  21.             logging.debug('TYPE %s' % (ctype))
  22.             logging.debug('PATH %s' % (self.path))
  23.             logging.debug('ARGS %d' % (len(postvars)))
  24.             if len(postvars):
RAW Paste Data
Top