Skip to content

Commit 07792af

Browse files
committed
Remove "raw" encoding. Rename "raws" to "binary".
Deprecation warnings have been added to help the conversion to this new API.
1 parent 2db7d67 commit 07792af

File tree

14 files changed

+189
-281
lines changed

14 files changed

+189
-281
lines changed

doc/api.html

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ <h2 id="_synopsis">SYNOPSIS</h2>
5555
</div>
5656
<h2 id="_api">API</h2>
5757
<div class="sectionbody">
58-
<div class="paragraph"><p>Node supports 4 byte-string encodings. ASCII (<tt>"ascii"</tt>), UTF-8 (<tt>"utf8"</tt>)
59-
both use the string object, obviously. Then two "raw binary" encodings - one
60-
uses an array of integers (<tt>"raw"</tt>) and the other uses a string (<tt>"raws"</tt>).
61-
Neither raw encodings are perfect and their implementations are rather
62-
inefficient. Hopefully the raw encoding situation will improve in the
63-
future.</p></div>
58+
<div class="paragraph"><p>Node supports 3 string encodings. UTF-8 (<tt>"utf8"</tt>), ASCII (<tt>"ascii"</tt>), and
59+
Binary (<tt>"binary"</tt>). <tt>"ascii"</tt> and <tt>"binary"</tt> only look at the first 8 bits
60+
of the 16bit javascript string characters. Both are relatively fast&#8212;use
61+
them if you can. <tt>"utf8"</tt> is slower and should be avoided when possible.</p></div>
6462
<div class="paragraph"><p>Unless otherwise noted, functions are all asynchronous and do not block
6563
execution.</p></div>
6664
<h3 id="_helpers">Helpers</h3><div style="clear:left"></div>
@@ -373,10 +371,9 @@ <h3 id="_standard_i_o">Standard I/O</h3><div style="clear:left"></div>
373371
<td align="left" valign="top"><p class="table"><tt>data</tt></p></td>
374372
<td align="left" valign="top"><p class="table">Made when stdin has received a chunk of data.
375373
Depending on the encoding that stdin was opened
376-
with, <tt>data</tt> will be either an array of integers
377-
(raw encoding) or a string (ascii or utf8
378-
encoding). This event will only be emited after
379-
<tt>node.stdio.open()</tt> has been called.</p></td>
374+
with, <tt>data</tt> will be a string. This event will
375+
only be emited after <tt>node.stdio.open()</tt> has
376+
been called.</p></td>
380377
</tr>
381378
<tr>
382379
<td align="left" valign="top"><p class="table"><tt>"close"</tt></p></td>
@@ -599,7 +596,8 @@ <h4 id="_tt_node_childprocess_tt"><tt>node.ChildProcess</tt></h4>
599596
<dd>
600597
<p>
601598
Write data to the child process&#8217;s <tt>stdin</tt>. The second argument is optional and
602-
specifies the encoding: possible values are <tt>"utf8"</tt>, <tt>"ascii"</tt>, and <tt>"raw"</tt>.
599+
specifies the encoding: possible values are <tt>"utf8"</tt>, <tt>"ascii"</tt>, and
600+
<tt>"binary"</tt>.
603601
</p>
604602
</dd>
605603
<dt class="hdlist1">
@@ -1050,8 +1048,7 @@ <h4 id="_tt_node_http_serverrequest_tt"><tt>node.http.ServerRequest</tt></h4>
10501048
<td align="left" valign="top"><p class="table"><tt>chunk</tt></p></td>
10511049
<td align="left" valign="top"><p class="table">Emitted when a piece of the message body is received. Example: A chunk of
10521050
the body is given as the single argument. The transfer-encoding has been
1053-
decoded. The body chunk is either a String in the case of UTF-8 encoding or
1054-
an array of numbers in the case of raw encoding. The body encoding is set
1051+
decoded. The body chunk is a String. The body encoding is set
10551052
with <tt>request.setBodyEncoding()</tt>.</p></td>
10561053
</tr>
10571054
<tr>
@@ -1123,8 +1120,8 @@ <h4 id="_tt_node_http_serverrequest_tt"><tt>node.http.ServerRequest</tt></h4>
11231120
</dt>
11241121
<dd>
11251122
<p>
1126-
Set the encoding for the request body. Either <tt>"utf8"</tt> or <tt>"raw"</tt>. Defaults
1127-
to raw.
1123+
Set the encoding for the request body. Either <tt>"utf8"</tt> or <tt>"binary"</tt>. Defaults
1124+
to <tt>"binary"</tt>.
11281125
</p>
11291126
</dd>
11301127
<dt class="hdlist1">
@@ -1380,9 +1377,8 @@ <h4 id="_tt_node_http_clientresponse_tt"><tt>node.http.ClientResponse</tt></h4>
13801377
<td align="left" valign="top"><p class="table"><tt>chunk</tt></p></td>
13811378
<td align="left" valign="top"><p class="table">Emitted when a piece of the message body is received. Example: A chunk of
13821379
the body is given as the single argument. The transfer-encoding has been
1383-
decoded. The body chunk is either a String in the case of UTF-8 encoding or
1384-
an array of numbers in the case of raw encoding. The body encoding is set
1385-
with <tt>response.setBodyEncoding()</tt>.</p></td>
1380+
decoded. The body chunk a String. The body encoding is set with
1381+
<tt>response.setBodyEncoding()</tt>.</p></td>
13861382
</tr>
13871383
<tr>
13881384
<td align="left" valign="top"><p class="table"><tt>"complete"</tt></p></td>
@@ -1424,8 +1420,8 @@ <h4 id="_tt_node_http_clientresponse_tt"><tt>node.http.ClientResponse</tt></h4>
14241420
</dt>
14251421
<dd>
14261422
<p>
1427-
Set the encoding for the response body. Either <tt>"utf8"</tt> or <tt>"raw"</tt>.
1428-
Defaults to raw.
1423+
Set the encoding for the response body. Either <tt>"utf8"</tt> or <tt>"binary"</tt>.
1424+
Defaults to <tt>"binary"</tt>.
14291425
</p>
14301426
</dd>
14311427
<dt class="hdlist1">
@@ -1574,11 +1570,9 @@ <h4 id="_tt_node_tcp_connection_tt"><tt>node.tcp.Connection</tt></h4>
15741570
<td align="left" valign="top"><p class="table"><tt>"receive"</tt></p></td>
15751571
<td align="left" valign="top"><p class="table"><tt>data</tt></p></td>
15761572
<td align="left" valign="top"><p class="table">Called when data is received on the
1577-
connection. Encoding of data is set
1578-
by <tt>connection.setEncoding()</tt>. <tt>data</tt>
1579-
will either be a string, in the case of
1580-
utf8, or an array of integer in the case
1581-
of raw encoding.</p></td>
1573+
connection. <tt>data</tt> will be a string.
1574+
Encoding of data is set by
1575+
<tt>connection.setEncoding()</tt>.</p></td>
15821576
</tr>
15831577
<tr>
15841578
<td align="left" valign="top"><p class="table"><tt>"eof"</tt></p></td>
@@ -1658,18 +1652,16 @@ <h4 id="_tt_node_tcp_connection_tt"><tt>node.tcp.Connection</tt></h4>
16581652
</dt>
16591653
<dd>
16601654
<p>
1661-
Sets the encoding (either <tt>"utf8"</tt> or <tt>"raw"</tt>) for data that is received.
1655+
Sets the encoding (either <tt>"ascii"</tt>, <tt>"utf8"</tt>, or <tt>"binary"</tt>) for data that is received.
16621656
</p>
16631657
</dd>
16641658
<dt class="hdlist1">
16651659
<tt>connection.send(data, encoding="ascii")</tt>
16661660
</dt>
16671661
<dd>
16681662
<p>
1669-
Sends data on the connection. The data should be eithre an array
1670-
of integers (for raw binary) or a string (for utf8 or ascii).
1671-
The second parameter specifies the encoding in the case of a
1672-
string&#8212;it defaults to ASCII because encoding to UTF8 is
1663+
Sends data on the connection. The second parameter specifies the encoding
1664+
in the case of a string&#8212;it defaults to ASCII because encoding to UTF8 is
16731665
rather slow.
16741666
</p>
16751667
</dd>
@@ -1930,7 +1922,7 @@ <h2 id="_extension_api">Extension API</h2>
19301922
<div id="footer">
19311923
<div id="footer-text">
19321924
Version 0.1.11<br />
1933-
Last updated 2009-09-18 18:31:06 CEST
1925+
Last updated 2009-09-21 12:26:35 CEST
19341926
</div>
19351927
</div>
19361928
</body>

doc/api.txt

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ Server running at http://127.0.0.1:8000/
3838

3939
== API
4040

41-
Node supports 4 byte-string encodings. ASCII (+"ascii"+), UTF-8 (+"utf8"+)
42-
both use the string object, obviously. Then two "raw binary" encodings - one
43-
uses an array of integers (+"raw"+) and the other uses a string (+"raws"+).
44-
Neither raw encodings are perfect and their implementations are rather
45-
inefficient. Hopefully the raw encoding situation will improve in the
46-
future.
41+
Node supports 3 string encodings. UTF-8 (+"utf8"+), ASCII (+"ascii"+), and
42+
Binary (+"binary"+). +"ascii"+ and +"binary"+ only look at the first 8 bits
43+
of the 16bit javascript string characters. Both are relatively fast--use
44+
them if you can. +"utf8"+ is slower and should be avoided when possible.
4745

4846
Unless otherwise noted, functions are all asynchronous and do not block
4947
execution.
@@ -222,10 +220,9 @@ synchronous.
222220

223221
| +"data"+ | +data+ | Made when stdin has received a chunk of data.
224222
Depending on the encoding that stdin was opened
225-
with, +data+ will be either an array of integers
226-
(raw encoding) or a string (ascii or utf8
227-
encoding). This event will only be emited after
228-
+node.stdio.open()+ has been called.
223+
with, +data+ will be a string. This event will
224+
only be emited after +node.stdio.open()+ has
225+
been called.
229226
| +"close"+ | | Made when stdin has been closed.
230227
|=========================================================
231228

@@ -394,7 +391,8 @@ The PID of the child process.
394391

395392
+child.write(data, encoding="ascii")+ ::
396393
Write data to the child process's +stdin+. The second argument is optional and
397-
specifies the encoding: possible values are +"utf8"+, +"ascii"+, and +"raw"+.
394+
specifies the encoding: possible values are +"utf8"+, +"ascii"+, and
395+
+"binary"+.
398396

399397

400398
+child.close()+ ::
@@ -640,8 +638,7 @@ the user--and passed as the first argument to a +"request"+ listener.
640638
|+"body"+ | +chunk+ |
641639
Emitted when a piece of the message body is received. Example: A chunk of
642640
the body is given as the single argument. The transfer-encoding has been
643-
decoded. The body chunk is either a String in the case of UTF-8 encoding or
644-
an array of numbers in the case of raw encoding. The body encoding is set
641+
decoded. The body chunk is a String. The body encoding is set
645642
with +request.setBodyEncoding()+.
646643

647644
|+"complete"+ | |
@@ -692,8 +689,8 @@ The HTTP protocol version as a string. Read only. Examples:
692689

693690

694691
+request.setBodyEncoding(encoding)+ ::
695-
Set the encoding for the request body. Either +"utf8"+ or +"raw"+. Defaults
696-
to raw.
692+
Set the encoding for the request body. Either +"utf8"+ or +"binary"+. Defaults
693+
to +"binary"+.
697694

698695

699696
+request.pause()+ ::
@@ -895,9 +892,8 @@ This object is created internally and passed to the +"response"+ event.
895892
|+"body"+ | +chunk+ |
896893
Emitted when a piece of the message body is received. Example: A chunk of
897894
the body is given as the single argument. The transfer-encoding has been
898-
decoded. The body chunk is either a String in the case of UTF-8 encoding or
899-
an array of numbers in the case of raw encoding. The body encoding is set
900-
with +response.setBodyEncoding()+.
895+
decoded. The body chunk a String. The body encoding is set with
896+
+response.setBodyEncoding()+.
901897

902898
|+"complete"+ | |
903899
Emitted exactly once for each message. No arguments.
@@ -916,8 +912,8 @@ After emitted no other events will be emitted on the response.
916912
The response headers.
917913

918914
+response.setBodyEncoding(encoding)+ ::
919-
Set the encoding for the response body. Either +"utf8"+ or +"raw"+.
920-
Defaults to raw.
915+
Set the encoding for the response body. Either +"utf8"+ or +"binary"+.
916+
Defaults to +"binary"+.
921917

922918
+response.pause()+ ::
923919
Pauses response from emitting events. Useful to throttle back a download.
@@ -1005,11 +1001,9 @@ socket for +node.tcp.Server+.
10051001
after a call to +createConnection()+ or
10061002
+connect()+.
10071003
|+"receive"+ | +data+ | Called when data is received on the
1008-
connection. Encoding of data is set
1009-
by +connection.setEncoding()+. +data+
1010-
will either be a string, in the case of
1011-
utf8, or an array of integer in the case
1012-
of raw encoding.
1004+
connection. +data+ will be a string.
1005+
Encoding of data is set by
1006+
+connection.setEncoding()+.
10131007
|+"eof"+ | | Called when the other end of the
10141008
connection sends a FIN packet.
10151009
After this is emitted the +readyState+
@@ -1055,13 +1049,11 @@ Either +"closed"+, +"open"+, +"opening"+, +"readOnly"+, or +"writeOnly"+.
10551049

10561050

10571051
+connection.setEncoding(encoding)+::
1058-
Sets the encoding (either +"utf8"+ or +"raw"+) for data that is received.
1052+
Sets the encoding (either +"ascii"+, +"utf8"+, or +"binary"+) for data that is received.
10591053

10601054
+connection.send(data, encoding="ascii")+::
1061-
Sends data on the connection. The data should be eithre an array
1062-
of integers (for raw binary) or a string (for utf8 or ascii).
1063-
The second parameter specifies the encoding in the case of a
1064-
string--it defaults to ASCII because encoding to UTF8 is
1055+
Sends data on the connection. The second parameter specifies the encoding
1056+
in the case of a string--it defaults to ASCII because encoding to UTF8 is
10651057
rather slow.
10661058

10671059

doc/node.1

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.\" Title: node
22
.\" Author:
33
.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
4-
.\" Date: 09/18/2009
4+
.\" Date: 09/21/2009
55
.\" Manual:
66
.\" Source:
77
.\"
8-
.TH "NODE" "1" "09/18/2009" "" ""
8+
.TH "NODE" "1" "09/21/2009" "" ""
99
.\" disable hyphenation
1010
.nh
1111
.\" disable justification (adjust text to left margin only)
@@ -38,7 +38,7 @@ Server running at http://127\.0\.0\.1:8000/
3838
.fi
3939
.RE
4040
.SH "API"
41-
Node supports 4 byte\-string encodings\. ASCII ("ascii"), UTF\-8 ("utf8") both use the string object, obviously\. Then two "raw binary" encodings \- one uses an array of integers ("raw") and the other uses a string ("raws")\. Neither raw encodings are perfect and their implementations are rather inefficient\. Hopefully the raw encoding situation will improve in the future\.
41+
Node supports 3 string encodings\. UTF\-8 ("utf8"), ASCII ("ascii"), and Binary ("binary")\. "ascii" and "binary" only look at the first 8 bits of the 16bit javascript string characters\. Both are relatively fast\(emuse them if you can\. "utf8" is slower and should be avoided when possible\.
4242
.sp
4343
Unless otherwise noted, functions are all asynchronous and do not block execution\.
4444
.sp
@@ -329,7 +329,7 @@ T}:T{
329329
data
330330
.sp
331331
T}:T{
332-
Made when stdin has received a chunk of data\. Depending on the encoding that stdin was opened with, data will be either an array of integers (raw encoding) or a string (ascii or utf8 encoding)\. This event will only be emited after node\.stdio\.open() has been called\.
332+
Made when stdin has received a chunk of data\. Depending on the encoding that stdin was opened with, data will be a string\. This event will only be emited after node\.stdio\.open() has been called\.
333333
.sp
334334
T}
335335
T{
@@ -558,7 +558,7 @@ Write data to the child process\(cqs
558558
stdin\. The second argument is optional and specifies the encoding: possible values are
559559
"utf8",
560560
"ascii", and
561-
"raw"\.
561+
"binary"\.
562562
.RE
563563
.PP
564564
child\.close()
@@ -946,7 +946,7 @@ T}:T{
946946
chunk
947947
.sp
948948
T}:T{
949-
Emitted when a piece of the message body is received\. Example: A chunk of the body is given as the single argument\. The transfer\-encoding has been decoded\. The body chunk is either a String in the case of UTF\-8 encoding or an array of numbers in the case of raw encoding\. The body encoding is set with request\.setBodyEncoding()\.
949+
Emitted when a piece of the message body is received\. Example: A chunk of the body is given as the single argument\. The transfer\-encoding has been decoded\. The body chunk is a String\. The body encoding is set with request\.setBodyEncoding()\.
950950
.sp
951951
T}
952952
T{
@@ -1030,7 +1030,8 @@ request\.setBodyEncoding(encoding)
10301030
Set the encoding for the request body\. Either
10311031
"utf8"
10321032
or
1033-
"raw"\. Defaults to raw\.
1033+
"binary"\. Defaults to
1034+
"binary"\.
10341035
.RE
10351036
.PP
10361037
request\.pause()
@@ -1300,7 +1301,7 @@ T}:T{
13001301
chunk
13011302
.sp
13021303
T}:T{
1303-
Emitted when a piece of the message body is received\. Example: A chunk of the body is given as the single argument\. The transfer\-encoding has been decoded\. The body chunk is either a String in the case of UTF\-8 encoding or an array of numbers in the case of raw encoding\. The body encoding is set with response\.setBodyEncoding()\.
1304+
Emitted when a piece of the message body is received\. Example: A chunk of the body is given as the single argument\. The transfer\-encoding has been decoded\. The body chunk a String\. The body encoding is set with response\.setBodyEncoding()\.
13041305
.sp
13051306
T}
13061307
T{
@@ -1338,7 +1339,8 @@ response\.setBodyEncoding(encoding)
13381339
Set the encoding for the response body\. Either
13391340
"utf8"
13401341
or
1341-
"raw"\. Defaults to raw\.
1342+
"binary"\. Defaults to
1343+
"binary"\.
13421344
.RE
13431345
.PP
13441346
response\.pause()
@@ -1502,7 +1504,7 @@ T}:T{
15021504
data
15031505
.sp
15041506
T}:T{
1505-
Called when data is received on the connection\. Encoding of data is set by connection\.setEncoding()\. data will either be a string, in the case of utf8, or an array of integer in the case of raw encoding\.
1507+
Called when data is received on the connection\. data will be a string\. Encoding of data is set by connection\.setEncoding()\.
15061508
.sp
15071509
T}
15081510
T{
@@ -1589,14 +1591,14 @@ Either
15891591
connection\.setEncoding(encoding)
15901592
.RS 4
15911593
Sets the encoding (either
1592-
"utf8"
1593-
or
1594-
"raw") for data that is received\.
1594+
"ascii",
1595+
"utf8", or
1596+
"binary") for data that is received\.
15951597
.RE
15961598
.PP
15971599
connection\.send(data, encoding="ascii")
15981600
.RS 4
1599-
Sends data on the connection\. The data should be eithre an array of integers (for raw binary) or a string (for utf8 or ascii)\. The second parameter specifies the encoding in the case of a string\(emit defaults to ASCII because encoding to UTF8 is rather slow\.
1601+
Sends data on the connection\. The second parameter specifies the encoding in the case of a string\(emit defaults to ASCII because encoding to UTF8 is rather slow\.
16001602
.RE
16011603
.PP
16021604
connection\.close()

src/file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ node.fs.cat = function (path, encoding) {
1414
cat_promise.emitError(new Error("Could not open " + path));
1515
});
1616
open_promise.addCallback(function (fd) {
17-
var content = (encoding === "raw" ? [] : "");
17+
var content = "";
1818
var pos = 0;
1919

2020
function readChunk () {

src/http.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ OutgoingMessage.prototype.send = function (data, encoding) {
178178

179179
if (length === 0) {
180180
this.output.push(data);
181-
encoding = encoding || (data.constructor === Array ? "raw" : "ascii");
181+
encoding = encoding || "ascii";
182182
this.outputEncodings.push(encoding);
183183
return;
184184
}
@@ -197,7 +197,7 @@ OutgoingMessage.prototype.send = function (data, encoding) {
197197
}
198198

199199
this.output.push(data);
200-
encoding = encoding || (data.constructor === Array ? "raw" : "ascii");
200+
encoding = encoding || "ascii";
201201
this.outputEncodings.push(encoding);
202202
};
203203

0 commit comments

Comments
 (0)