摘要身份驗證(如何使用Node.js,快遞,護照-HTTP)curl命令的使用JSON後
我有一個POST路線做消化權威性,試圖應用JSON內容類型。
我可以用摘要命中GET路由,沒有問題,我可以用基本身份驗證打開POST路由而沒有問題,但是當我嘗試使用摘要身份驗證執行POST時,我得到400 - 錯誤請求。它看起來像curl把內容類型放在初始摘要請求上(內容長度爲0,所以它知道足夠的不在初始digest-auth請求上發送json正文),並且我的一方(express)失敗無效JSON(空體):
$ 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'
> POST /user HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: 127.0.0.1:3002
> Accept: */*
> content-type: application/json
> Content-Length: 0
>
< HTTP/1.1 400 Bad Request
< X-Powered-By: Express
< Content-Type: text/plain
< Date: Thu, 21 Mar 2013 15:33:10 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
我似乎無法找出捲曲魔發送摘要初始分組不這樣做,僅增加內容類型在後面的實際的數據的請求。
供參考,但我不認爲這會有所幫助,這裏是同一呼叫的BASIC成績單:
$ 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'
> POST /user HTTP/1.1
> Authorization: Basic b3JnMnVzZXIyOmxhbWVkdWNr
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: 127.0.0.1:3002
> Accept: */*
> content-type: application/json
> Content-Length: 48
>
* upload completely sent off: 48 out of 48 bytes
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: application/json; charset=utf-8
< Content-Length: 51
< Date: Thu, 21 Mar 2013 15:43:48 GMT
< Connection: keep-alive
<
{
"this": "is working",
"that": "is annoying"
* Connection #0 to host 127.0.0.1 left intact
}* Closing connection #0
任何幫助將是真棒。