title: Why is environ['QUERY_STRING'] returning a zero length string?
body: <p>I found the solution to my (dumb) problem and listed it below.</p>
  
  <p>I'm using Python 2.7.1+ on Ubuntu 11.04. The client/server are on the same computer.</p>
  
  <p>From the Wing debugger, I know the server code is being called and I can walk through the code one line at a time.  In this instance, I know 22 bytes were transferred.</p>
  
  <p>In Firebug, I saw this data under the Net Post tab:</p>
  
  <pre><code>Parameter   application/x-www-form-urlencoded
  fname   first
  lname   last
  Source
  Content-Type: application/x-www-form-urlencoded
  Content-Length: 22 fname=first&amp;lname=last
  </code></pre>
  
  <p>This is the client code that I'm using:</p>
  
  <pre><code>&lt;html&gt;
       &lt;form action="addGraphNotes.wsgi" method="post"&gt;
           First name: &lt;input type="text" name="fname" /&gt;&lt;br /&gt;
           Last name: &lt;input type="text" name="lname" /&gt;&lt;br /&gt;
           &lt;input type="submit" value="Submit" /&gt;
      &lt;/form&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is the server code:</p>
  
  <pre><code>import urlparse 
  
  def application(environ, start_response):
      output = []
  
      # the environment variable CONTENT_LENGTH may be empty or missing
      try:
      # NOTE: THIS WORKS. I get a value &gt; 0 and the size appears correct (22 bytes in this case)
          request_body_size = int(environ.get('CONTENT_LENGTH', 0))
      except (ValueError):
          request_body_size = 0
  
      try:
          # environ['QUERY_STRING'] returns ""
          **values = urlparse.parse_qs( environ['QUERY_STRING'] )**
      except:
          output = ["parse error"]
  </code></pre>
  
  <p>In the Wing debugger, I've verified that data is being passed from the client to the server:</p>
  
  <pre><code>&gt;&gt;&gt; environ['wsgi.input'].read()
  'fname=first&amp;lname=last'
  </code></pre>
  
  <p><strong>FOUND MY PROBLEM. I COPIED AND PASTED IN THE WRONG CODE. THIS IS THE CODE I WAS USING FOR FORMS BUT STOP ADDING IT WHEN I STARTED USING AJAX AND STOPPED USING FORMS. Now, everything is working fine.</strong></p>
  
  <pre><code># When the method is POST the query string will be sent
  # in the HTTP request body which is passed by the WSGI server
  # in the file like wsgi.input environment variable.
  request_body = environ['wsgi.input'].read(request_body_size)
  
  values = parse_qs(request_body) 
  </code></pre>