摘要身份验证(如何使用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
任何帮助将是真棒。