From 8553e8a15d0ff3715fb3a8a02062de9dcb9339b6 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 11 Apr 2010 15:15:36 -0700 Subject: [PATCH] Add incoming.httpVersion --- doc/api.markdown | 6 +++++- lib/http.js | 3 +++ test/simple/test-http-1.0.js | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/api.markdown b/doc/api.markdown index a9c3e06954..525743c3a4 100644 --- a/doc/api.markdown +++ b/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 diff --git a/lib/http.js b/lib/http.js index da6cb384d9..12130b68b6 100644 --- a/lib/http.js +++ b/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 diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js index 248c7fc502..534a408236 100644 --- a/test/simple/test-http-1.0.js +++ b/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); })