Browse Source

Add incoming.httpVersion

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
8553e8a15d
  1. 6
      doc/api.markdown
  2. 3
      lib/http.js
  3. 3
      test/simple/test-http-1.0.js

6
doc/api.markdown

@ -1448,7 +1448,9 @@ Read only.
### request.httpVersion
The HTTP protocol version as a string. Read only. Examples:
`'1.1'`, `'1.0'`
`'1.1'`, `'1.0'`.
Also `request.httpVersionMajor` is the first integer and
`request.httpVersionMinor` is the second.
### request.setEncoding(encoding='binary')
@ -1674,6 +1676,8 @@ The 3-digit HTTP response status code. E.G. `404`.
The HTTP version of the connected-to server. Probably either
`'1.1'` or `'1.0'`.
Also `response.httpVersionMajor` is the first integer and
`response.httpVersionMinor` is the second.
### response.headers

3
lib/http.js

@ -70,6 +70,9 @@ function newParser (type) {
parser.incoming.httpVersionMajor = info.versionMajor;
parser.incoming.httpVersionMinor = info.versionMinor;
parser.incoming.httpVersion = info.versionMajor
+ '.'
+ info.versionMinor ;
if (info.method) {
// server only

3
test/simple/test-http-1.0.js

@ -7,6 +7,9 @@ var server_response = "";
var client_got_eof = false;
var server = http.createServer(function (req, res) {
assert.equal('1.0', req.httpVersion);
assert.equal(1, req.httpVersionMajor);
assert.equal(0, req.httpVersionMinor);
res.writeHead(200, {"Content-Type": "text/plain"});
res.end(body);
})

Loading…
Cancel
Save