0
我編寫了一個HTTPS NodeJS服務器(帶有自簽名證書),用於接收和處理來自cURL CLI的POST請求。使用cURL CLI到NodeJS服務器的HTTPS POST
我的服務器:我使用
var https = require('https');
var fs = require('fs');
var config = require('./conf.json');
var g3updater_kernel = require('./g3updater_kernel');
var express = require('express');
var app = express();
var privateKey = fs.readFileSync(config.security_repository+'/CA/rootCA.key', 'utf8');
var certificate = fs.readFileSync(config.security_repository+'/CA/rootCA.pem', 'utf8');
var httpsOptions = {
key: privateKey,
cert: certificate
}
app.post('/', function(req, res){
console.log(req.query);
});
https.createServer(httpsOptions, app).listen(443);
cURL命令:
curl -d M=1 https://localhost/ -k
的問題是,我收到一個空的查詢。 console.log(req.query)
顯示:
{}
我在查詢中丟失了什麼?
看看這篇文章是否可以幫助你[在curl上進行發佈](http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-請求) –