Skip to content

Commit b1b8496

Browse files
Benjamin Thomasry
authored andcommitted
Rename writeHeader to writeHead
1 parent b08f2af commit b1b8496

19 files changed

Lines changed: 29 additions & 28 deletions

benchmark/http_simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ http.createServer(function (req, res) {
4747

4848
var content_length = body.length.toString();
4949

50-
res.writeHeader( status
50+
res.writeHead( status
5151
, { "Content-Type": "text/plain"
5252
, "Content-Length": content_length
5353
}

benchmark/static_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for (var i = 0; i < bytes; i++) {
1616
}
1717

1818
var server = http.createServer(function (req, res) {
19-
res.writeHeader(200, {
19+
res.writeHead(200, {
2020
"Content-Type": "text/plain",
2121
"Content-Length": body.length
2222
});

doc/api.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ World":
1919
var sys = require("sys"),
2020
http = require("http");
2121
http.createServer(function (request, response) {
22-
response.writeHeader(200, {"Content-Type": "text/plain"});
22+
response.writeHead(200, {"Content-Type": "text/plain"});
2323
response.write("Hello World\n");
2424
response.close();
2525
}).listen(8000);
@@ -951,7 +951,7 @@ The +http.Connection+ object.
951951
This object is created internally by a HTTP server--not by the user. It is
952952
passed as the second parameter to the +"request"+ event.
953953

954-
+response.writeHeader(statusCode[, reasonPhrase] , headers)+ ::
954+
+response.writeHead(statusCode[, reasonPhrase] , headers)+ ::
955955

956956
Sends a response header to the request. The status code is a 3-digit HTTP
957957
status code, like +404+. The last argument, +headers+, are the response headers.
@@ -962,7 +962,7 @@ Example:
962962
+
963963
----------------------------------------
964964
var body = "hello world";
965-
response.writeHeader(200, {
965+
response.writeHead(200, {
966966
"Content-Length": body.length,
967967
"Content-Type": "text/plain"
968968
});
@@ -973,7 +973,7 @@ be called before +response.close()+ is called.
973973

974974
+response.write(chunk, encoding="ascii")+ ::
975975

976-
This method must be called after +writeHeader+ was
976+
This method must be called after +writeHead+ was
977977
called. It sends a chunk of the response body. This method may
978978
be called multiple times to provide successive parts of the body.
979979
+
@@ -1297,7 +1297,7 @@ http.createServer(function (req, res) {
12971297
fields = {},
12981298
name, filename;
12991299
mp.addListener("error", function (er) {
1300-
res.writeHeader(400, {"content-type":"text/plain"});
1300+
res.writeHead(400, {"content-type":"text/plain"});
13011301
res.write("You sent a bad message!\n"+er.message);
13021302
res.close();
13031303
});
@@ -1317,7 +1317,7 @@ http.createServer(function (req, res) {
13171317
});
13181318
mp.addListener("complete", function () {
13191319
var response = "You posted: \n" + sys.inspect(fields);
1320-
res.writeHeader(200, {
1320+
res.writeHead(200, {
13211321
"content-type" : "text/plain",
13221322
"content-length" : response.length
13231323
});

doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
http = require('http');
4949
http.createServer(function (req, res) {
5050
setTimeout(function () {
51-
res.writeHeader(200, {'Content-Type': 'text/plain'});
51+
res.writeHead(200, {'Content-Type': 'text/plain'});
5252
res.write('Hello World');
5353
res.close();
5454
}, 2000);

lib/http.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ sys.inherits(ServerResponse, OutgoingMessage);
257257
exports.ServerResponse = ServerResponse;
258258

259259

260-
ServerResponse.prototype.writeHeader = function (statusCode) {
260+
ServerResponse.prototype.writeHead = function (statusCode) {
261261
var reasonPhrase, headers, headerIndex;
262262

263263
if (typeof arguments[1] == 'string') {
@@ -279,8 +279,9 @@ ServerResponse.prototype.writeHeader = function (statusCode) {
279279
this.sendHeaderLines(status_line, headers);
280280
};
281281

282-
// TODO eventually remove sendHeader()
283-
ServerResponse.prototype.sendHeader = ServerResponse.prototype.writeHeader;
282+
// TODO eventually remove sendHeader(), writeHeader()
283+
ServerResponse.prototype.sendHeader = ServerResponse.prototype.writeHead;
284+
ServerResponse.prototype.writeHeader = ServerResponse.prototype.writeHead;
284285

285286
function ClientRequest (method, url, headers) {
286287
OutgoingMessage.call(this);

test/pummel/test-keep-alive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PORT = 8891;
66

77
body = "hello world\n";
88
server = http.createServer(function (req, res) {
9-
res.writeHeader(200, {
9+
res.writeHead(200, {
1010
"Content-Length": body.length,
1111
"Content-Type": "text/plain",
1212
});

test/pummel/test-multipart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ var server = http.createServer(function (req, res) {
7777
}
7878
mp.addListener("error", function (er) {
7979
sys.puts("!! error occurred");
80-
res.writeHeader(400, {});
80+
res.writeHead(400, {});
8181
res.write("bad");
8282
res.close();
8383
});
8484
mp.addListener("complete", function () {
85-
res.writeHeader(200, {});
85+
res.writeHead(200, {});
8686
res.write("ok");
8787
res.close();
8888
});

test/simple/test-http-1.0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var server_response = "";
99
var client_got_eof = false;
1010

1111
var server = http.createServer(function (req, res) {
12-
res.writeHeader(200, {"Content-Type": "text/plain"});
12+
res.writeHead(200, {"Content-Type": "text/plain"});
1313
res.write(body);
1414
res.close();
1515
})

test/simple/test-http-cat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PORT = 8888;
55
var body = "exports.A = function() { return 'A';}";
66
var server = http.createServer(function (req, res) {
77
puts("got request");
8-
res.writeHeader(200, [
8+
res.writeHead(200, [
99
["Content-Length", body.length],
1010
["Content-Type", "text/plain"]
1111
]);

test/simple/test-http-chunked.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var PORT = 8888;
55
var UTF8_STRING = "Il était tué";
66

77
var server = http.createServer(function(req, res) {
8-
res.writeHeader(200, {"Content-Type": "text/plain; charset=utf8"});
8+
res.writeHead(200, {"Content-Type": "text/plain; charset=utf8"});
99
res.write(UTF8_STRING, 'utf8');
1010
res.close();
1111
});

0 commit comments

Comments
 (0)