var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
server.listen(8000);
console.log("Server running at http://127.0.0.1:8000/");
codiert I folgende curl Befehle ausgeführt:Node.js: curl: (52) Leere Antwort vom Server mit Platz in Anfrage nicht
curl "http://127.0.0.1:8000/"
Hello World
// space is not encoded
curl "http://127.0.0.1:8000/x y"
curl: (52) Empty reply from server
curl "http://127.0.0.1:8000/x"
Hello World
// space is encoded
curl "http://127.0.0.1:8000/x%20y"
Hello World
Können Sie mir bitte erklären, warum ich die Locke 52 bekommen ?? ?
In diesem Fall möchte ich 500 zurück senden. Kann ich das machen?
Wir brauchen den Rest des Knotenkodes und die Curl-Befehlszeile. Hoffentlich gibt es dort einen res.Send ... – Paul
'app.get ('/ item/id')' bedeutet wörtlich '/ item/id' nicht'/item/item1' – Paul
Probieren Sie '-I' curls Option für Erläuterung. (Auf meiner Maschine curl sendet 2 Anfragen für 'curl http: // google.com/xy' Befehl: erstens zu Google Server und zweitens zu' y'.) – elmigranto