节点以URL

时间:2016-10-13 20:59:25

标签: node.js http

让我们开始简单的服务器:

var http = require('http');    
http.createServer(function (req, res) {
    console.log('asdasd');
    res.end('asdasd');
}).listen(8898)

并提出简单的请求

curl -v 'localhost:8898/?ab'
*   Trying ::1...
* Connected to localhost (::1) port 8898 (#0)
> GET /?ab HTTP/1.1
> Host: localhost:8898
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 13 Oct 2016 20:26:14 GMT
< Connection: keep-alive
< Content-Length: 6
<
* Connection #0 to host localhost left intact
asdasd

看起来一切都很好。 但是如果我们为它添加一个文字空间......

cornholio-osx:~/>curl -v 'localhost:8898/?a b'
*   Trying ::1...
* Connected to localhost (::1) port 8898 (#0)
> GET /?a b HTTP/1.1
> Host: localhost:8898
> User-Agent: curl/7.43.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact

没有记录任何内容,也没有写入正文。

我认为,URL中的文字空间违反了HTTP协议,但这种行为是HTTP投诉吗?

0 个答案:

没有答案