title: CouchDB 1.0.2 http_post_data on View from PHP Pecl Error Bad Content Type
body: <p>First, here is what my current system looks like:</p>
  
  <ul>
  <li>CouchDB 1.0.2</li>
  <li>PHP 5.3.6</li>
  <li>Apache httpd 2.2.19</li>
  <li>PECL http 1.7.1</li>
  <li>CouchDB-Lucene 0.6.1</li>
  </ul>
  
  <p>I am building a mini search engine with CouchDB and CouchDB-Lucene. When the user enters a query I POST to my PHP script which then queries couchdb-lucene. Couchdb-lucene will then return a list of matching document keys to the PHP script. Then, I POST data (with http_post_data) to a List Function with that list of keys (<a href="http://wiki.apache.org/couchdb/HTTP_view_API" rel="nofollow">detailed here</a>, under "Querying Options"). This List Function returns HTML formatted results. This is the part that works.</p>
  
  <p>My needs are now changing and I would like to query only the view and get back JSON. However, when I do, this is the response from the http_post_data call:</p>
  
  <p><code>
  HTTP/1.1 415 Unsupported Media Type
  Server: CouchDB/1.0.2 (Erlang OTP/R13B)
  Date: Sat, 09 Jul 2011 22:22:51 GMT
  Content-Type: text/plain;charset=utf-8
  Content-Length: 78
  Cache-Control: must-revalidate
  {"error":"bad_content_type","reason":"Content-Type must be application/json"}
  </code></p>
  
  <p>The URL that I generate for this view is correct. I can change my POST call to</p>
  
  <p><code>
  http_post_data(url/of/view, $key_string, "Content-Type:application/json");
  </code></p>
  
  <p>but nothing will actually be returned (I am looking at output in Firebug). To send back my results, here is the relevant PHP:</p>
  
  <p><code>
  HttpResponse::setContentType("application/json");
  HttpResponse::setData($response);
  </code></p>
  
  <p><code>$response</code> contains the response from the http_post_data call to CouchDB.</p>
  
  <p>Any suggestions? This has been driving me mad for a day and a bit now.</p>
  
  <p>Thanks.</p>