spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

Using node-spdy to start the http2 server, some special request methods cannot be recognized. #370

Open masx200 opened 4 years ago

masx200 commented 4 years ago

Using node-spdy to start the http2 server, some special request methods cannot be recognized.

For some strange request methods,req.method is null

index.js

var spdy = require('spdy');
var fs = require('fs');

var options = {
    // Private key
    key: fs.readFileSync(__dirname + '/key.pem'),

    // Fullchain file or cert file (prefer the former)
    cert: fs.readFileSync(__dirname + '/cert.pem'),

    // **optional** SPDY-specific options
};

var server = spdy.createServer(options, function (req, res) {
    res.writeHead(200);
    res.end('method:' + req.method);
});

server.listen(3000);

package.json

{
  "dependencies": {
    "spdy": "^4.0.2"
  }
}
node -v
v14.3.0
node index.js

Open it in chrome browser.

https://localhost:3000/

Enter the following code in the console in devtools,

fetch(location.href,{method:"GET"}).then(r=>r.text()).then(console.log)
Promise {<pending>}
method:GET

I made a HEAD method request but received the response body?

fetch(location.href,{method:"HEAD"}).then(r=>r.text()).then(console.log)
Promise {<pending>}
method:HEAD

Initiating certain requests, the method cannot be correctly identified.

fetch(location.href,{method:"MKWORKSPACE"}).then(r=>r.text()).then(console.log)
Promise {<pending>}
method:null

fetch(location.href,{method:"VERSION-CONTROL"}).then(r=>r.text()).then(console.log)
Promise {<pending>}
method:null
fetch(location.href,{method:"UPDATE"}).then(r=>r.text()).then(console.log)
Promise {<pending>}
method:null
masx200 commented 4 years ago

@indutny @anandsuresh @eee-c @anandsuresh @daviddias