title: Curl command for digest auth using a json post
body: <p>(Using node.js, express, passport-http) </p>
  
  <p>I have a POST route doing digest auth, trying to application-json content type. </p>
  
  <p>I can hit the GET route with digest, without issues, and I can hit the POST route with basic auth without issues, but when I try to do the POST with digest auth, I'm getting 400 - Bad Request.  It  looks like curl puts the content-type on the initial digest request (with a content-length of 0, so it knows enough not to send the json body on the initial digest-auth request), and my side (express) fails with invalid json (empty body):</p>
  
  <pre><code>$ curl  -v --digest  -X POST --data @body.json --user org2user2:lameduck -H "content-type: application/json"  http://127.0.0.1:3002/user
  
  * About to connect() to 127.0.0.1 port 3002 (#0)
  *   Trying 127.0.0.1...
  * connected
  * Connected to 127.0.0.1 (127.0.0.1) port 3002 (#0)
  * Server auth using Digest with user 'org2user2'
  &gt; POST /user HTTP/1.1
  &gt; User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
  &gt; Host: 127.0.0.1:3002
  &gt; Accept: */*
  &gt; content-type: application/json
  &gt; Content-Length: 0
  &gt; 
  &lt; HTTP/1.1 400 Bad Request
  &lt; X-Powered-By: Express
  &lt; Content-Type: text/plain
  &lt; Date: Thu, 21 Mar 2013 15:33:10 GMT
  &lt; Connection: keep-alive
  &lt; Transfer-Encoding: chunked
  </code></pre>
  
  <p>I can't seem to figure out the curl magic to send the digest initial packet without this, only adding the content-type in the actual data request that follows. </p>
  
  <p>For reference, although I don't think it helps, here is the BASIC transcript for the same call:</p>
  
  <pre><code>$ curl  -v --basic  -X POST --data @body.json --user org2user2:lameduck -H "content-type: application/json"  http://127.0.0.1:3002/user
  * About to connect() to 127.0.0.1 port 3002 (#0)
  *   Trying 127.0.0.1...
  * connected
  * Connected to 127.0.0.1 (127.0.0.1) port 3002 (#0)
  * Server auth using Basic with user 'org2user2'
  &gt; POST /user HTTP/1.1
  &gt; Authorization: Basic b3JnMnVzZXIyOmxhbWVkdWNr
  &gt; User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
  &gt; Host: 127.0.0.1:3002
  &gt; Accept: */*
  &gt; content-type: application/json
  &gt; Content-Length: 48
  &gt; 
  * upload completely sent off: 48 out of 48 bytes
  &lt; HTTP/1.1 200 OK
  &lt; X-Powered-By: Express
  &lt; Content-Type: application/json; charset=utf-8
  &lt; Content-Length: 51
  &lt; Date: Thu, 21 Mar 2013 15:43:48 GMT
  &lt; Connection: keep-alive
  &lt; 
  {
    "this": "is working",
    "that": "is annoying"
  * Connection #0 to host 127.0.0.1 left intact
  }* Closing connection #0
  </code></pre>
  
  <p>Any help would be awesome. </p>