Browse files

Add incoming.httpVersion

  • Loading branch information...
1 parent 57fbb62 commit 8553e8a15d0ff3715fb3a8a02062de9dcb9339b6 @ry ry committed Apr 11, 2010
Showing with 11 additions and 1 deletion.
  1. +5 −1 doc/api.markdown
  2. +3 −0 lib/http.js
  3. +3 −0 test/simple/test-http-1.0.js
View
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
View
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
View
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);
})

0 comments on commit 8553e8a

Please sign in to comment.