title: How do I access the data sent to my server using BaseHTTPRequestHandler?
body: <p>I'm a newbie to Python (using v3.3) and web programing and I've been struggling with a problem all night.  I'm issuing a POST call to my server and sending it some data as follows:</p>
  
  <pre><code>DATA = {"listName":"Test list","listDesc":"A test list with test stuff in it.","refreshMode":"Replace","DBKey":"1","UserDisplaySeq":"1"}
  DATA = json.dumps(DATA)
  METHOD = "POST"
  DATA = DATA.encode("utf-8")
  params = "account_id=acct 2"
  try:
      URL = "http://localhost:8080/lists?" + quote_plus(params)
      request = urllib.request.Request(url=URL,data=DATA,method=METHOD)
      response = urllib.request.urlopen(request)
  ...
  </code></pre>
  
  <p>I also have a request handler coded as follows (there are lot of print statements in here for debugging purposes):</p>
  
  <pre><code>class MyHandler(BaseHTTPRequestHandler):
  ...
  def do_POST(self):
      length = int(self.headers['Content-Length'])
      print("HEADERS: ", self.headers)
      print (str(length))
      print(self.rfile)
      post_data = urllib.parse.parse_qs(self.rfile.read(length).decode('utf-8'))
      print(post_data)
  </code></pre>
  
  <p>This prints the following result to the console:</p>
  
  <pre><code>Starting thread
  started httpserver...
  HEADERS:  Accept-Encoding: identity
  User-Agent: Python-urllib/3.3
  Content-Length: 138
  Content-Type: application/x-www-form-urlencoded
  Host: localhost:8080
  Connection: close
  
  
  138
  &lt;_io.BufferedReader name=404&gt;
  {}
  </code></pre>
  
  <p>My questions:<br>
  1) In the server (do_POST), how do I access the data I think I'm sending with my request (i.e. {"listName":"Test list","listDesc":"A test...)?</p>
  
  <p>2) Is my request even sending the data in the first place?</p>
  
  <p>3) Is there a place where this is documented in novice-accessible terms?</p>