OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #library('http'); |
| 6 #import('node.dart'); |
| 7 #import('net.dart', prefix:'net'); |
| 8 #import('url.dart'); |
| 9 |
| 10 // module http |
| 11 |
| 12 class http native "require('http')" { |
| 13 static Server createServer([ServerRequestListener listener]) native; |
| 14 static ClientRequest request(UrlObject options, void response(ServerResponse |
| 15 res)) |
| 16 native; |
| 17 static ClientRequest get(UrlObject options, void response(ServerResponse res)) |
| 18 native; |
| 19 static Agent globalAgent; |
| 20 } |
| 21 |
| 22 typedef void ServerRequestListener( |
| 23 ServerRequest request, ServerResponse response); |
| 24 typedef void ServerConnectionListener(net.Socket socket); |
| 25 typedef void ServerCloseListener(); |
| 26 typedef void ServerCheckContinueListener( |
| 27 ServerRequest request, ServerResponse response); |
| 28 typedef void ServerUpgradeListener( |
| 29 ServerRequest request, net.Socket socket, Buffer head); |
| 30 typedef void ServerClientErrorListener(Error exception); |
| 31 |
| 32 class Server native "require('http').Server" { |
| 33 // Implement EventEmitter |
| 34 void removeAllListeners(String event) |
| 35 native "this.removeAllListeners(event);"; |
| 36 void setMaxListeners(num n) |
| 37 native "this.setMaxListeners(n);"; |
| 38 var _listeners(String key) |
| 39 native "return this.listeners(key);"; |
| 40 |
| 41 // request event |
| 42 void emitRequest(ServerRequest request, ServerResponse response) |
| 43 native "this.emit('request');"; |
| 44 void addListenerRequest(ServerRequestListener listener) |
| 45 native "this.addListener('request', listener);"; |
| 46 void onRequest(ServerRequestListener listener) |
| 47 native "this.on('request', listener);"; |
| 48 void onceRequest(ServerRequestListener listener) |
| 49 native "this.once('request', listener);"; |
| 50 void removeListenerRequest(ServerRequestListener listener) |
| 51 native "this.removeListener('request', listener);"; |
| 52 List<ServerRequestListener> listenersRequest() |
| 53 => new _NativeListPrimitiveElement<ServerRequestListener>( |
| 54 _listeners('request')); |
| 55 |
| 56 // connection event |
| 57 void emitConnection(net.Socket socket) |
| 58 native "this.emit('connection');"; |
| 59 void addListenerConnection(ServerConnectionListener listener) |
| 60 native "this.addListener('connection', listener);"; |
| 61 void onConnection(ServerConnectionListener listener) |
| 62 native "this.on('connection', listener);"; |
| 63 void onceConnection(ServerConnectionListener listener) |
| 64 native "this.once('connection', listener);"; |
| 65 void removeListenerConnection(ServerConnectionListener listener) |
| 66 native "this.removeListener('connection', listener);"; |
| 67 List<ServerConnectionListener> listenersConnection() |
| 68 => new _NativeListPrimitiveElement<ServerConnectionListener>( |
| 69 _listeners('connection')); |
| 70 |
| 71 // close event |
| 72 void emitClose() |
| 73 native "this.emit('close');"; |
| 74 void addListenerClose(ServerCloseListener listener) |
| 75 native "this.addListener('close', listener);"; |
| 76 void onClose(ServerCloseListener listener) |
| 77 native "this.on('close', listener);"; |
| 78 void onceClose(ServerCloseListener listener) |
| 79 native "this.once('close', listener);"; |
| 80 void removeListenerClose(ServerCloseListener listener) |
| 81 native "this.removeListener('close', listener);"; |
| 82 List<ServerCloseListener> listenersClose() |
| 83 => new _NativeListPrimitiveElement<ServerCloseListener>( |
| 84 _listeners('close')); |
| 85 |
| 86 // checkContinue event |
| 87 void emitCheckContinue(ServerRequest request, ServerResponse response) |
| 88 native "this.emit('checkContinue');"; |
| 89 void addListenerCheckContinue(ServerCheckContinueListener listener) |
| 90 native "this.addListener('checkContinue', listener);"; |
| 91 void onCheckContinue(ServerCheckContinueListener listener) |
| 92 native "this.on('checkContinue', listener);"; |
| 93 void onceCheckContinue(ServerCheckContinueListener listener) |
| 94 native "this.once('checkContinue', listener);"; |
| 95 void removeListenerCheckContinue(ServerCheckContinueListener listener) |
| 96 native "this.removeListener('checkContinue', listener);"; |
| 97 List<ServerCheckContinueListener> listenersCheckContinue() |
| 98 => new _NativeListPrimitiveElement<ServerCheckContinueListener>( |
| 99 _listeners('checkContinue')); |
| 100 |
| 101 // upgrade event |
| 102 void emitUpgrade(ServerRequest request, net.Socket socket, Buffer head) |
| 103 native "this.emit('upgrade');"; |
| 104 void addListenerUpgrade(ServerUpgradeListener listener) |
| 105 native "this.addListener('upgrade', listener);"; |
| 106 void onUpgrade(ServerUpgradeListener listener) |
| 107 native "this.on('upgrade', listener);"; |
| 108 void onceUpgrade(ServerUpgradeListener listener) |
| 109 native "this.once('upgrade', listener);"; |
| 110 void removeListenerUpgrade(ServerUpgradeListener listener) |
| 111 native "this.removeListener('upgrade', listener);"; |
| 112 List<ServerUpgradeListener> listenersUpgrade() |
| 113 => new _NativeListPrimitiveElement<ServerUpgradeListener>( |
| 114 _listeners('upgrade')); |
| 115 |
| 116 // clientError event |
| 117 void emitClientError(Error exception) |
| 118 native "this.emit('clientError');"; |
| 119 void addListenerClientError(ServerClientErrorListener listener) |
| 120 native "this.addListener('clientError', listener);"; |
| 121 void onClientError(ServerClientErrorListener listener) |
| 122 native "this.on('clientError', listener);"; |
| 123 void onceClientError(ServerClientErrorListener listener) |
| 124 native "this.once('clientError', listener);"; |
| 125 void removeListenerClientError(ServerClientErrorListener listener) |
| 126 native "this.removeListener('clientError', listener);"; |
| 127 List<ServerClientErrorListener> listenersClientError() |
| 128 => new _NativeListPrimitiveElement<ServerClientErrorListener>( |
| 129 _listeners('clientError')); |
| 130 |
| 131 void listen(int port, [String hostname, void callback()]) native; |
| 132 void listenUnix(String path, [void callback()]) native; |
| 133 void close() native; |
| 134 } |
| 135 |
| 136 typedef void ServerRequestDataListener(var chunk); |
| 137 typedef void ServerRequestEndListener(); |
| 138 typedef void ServerRequestCloseListener(); |
| 139 |
| 140 class ServerRequest implements EventEmitter native |
| 141 "request('http').IncomingMessage" { |
| 142 // EventEmitter |
| 143 void removeAllListeners(String event) |
| 144 native "this.removeAllListeners(event);"; |
| 145 void setMaxListeners(num n) |
| 146 native "this.setMaxListeners(n);"; |
| 147 var _listeners(String key) |
| 148 native "return this.listeners(key);"; |
| 149 |
| 150 // data event |
| 151 void emitData(var chunk) |
| 152 native "this.emit('data');"; |
| 153 void addListenerData(ServerRequestDataListener listener) |
| 154 native "this.addListener('data', listener);"; |
| 155 void onData(ServerRequestDataListener listener) |
| 156 native "this.on('data', listener);"; |
| 157 void onceData(ServerRequestDataListener listener) |
| 158 native "this.once('data', listener);"; |
| 159 void removeListenerData(ServerRequestDataListener listener) |
| 160 native "this.removeListener('data', listener);"; |
| 161 List<ServerRequestDataListener> listenersData() |
| 162 => new _NativeListPrimitiveElement<ServerRequestDataListener>( |
| 163 _listeners('data')); |
| 164 |
| 165 // end event |
| 166 void emitEnd() |
| 167 native "this.emit('end');"; |
| 168 void addListenerEnd(ServerRequestEndListener listener) |
| 169 native "this.addListener('end', listener);"; |
| 170 void onEnd(ServerRequestEndListener listener) |
| 171 native "this.on('end', listener);"; |
| 172 void onceEnd(ServerRequestEndListener listener) |
| 173 native "this.once('end', listener);"; |
| 174 void removeListenerEnd(ServerRequestEndListener listener) |
| 175 native "this.removeListener('end', listener);"; |
| 176 List<ServerRequestEndListener> listenersEnd() |
| 177 => new _NativeListPrimitiveElement<ServerRequestEndListener>( |
| 178 _listeners('end')); |
| 179 |
| 180 // close event |
| 181 void emitClose() |
| 182 native "this.emit('close');"; |
| 183 void addListenerClose(ServerRequestCloseListener listener) |
| 184 native "this.addListener('close', listener);"; |
| 185 void onClose(ServerRequestCloseListener listener) |
| 186 native "this.on('close', listener);"; |
| 187 void onceClose(ServerRequestCloseListener listener) |
| 188 native "this.once('close', listener);"; |
| 189 void removeListenerClose(ServerRequestCloseListener listener) |
| 190 native "this.removeListener('close', listener);"; |
| 191 List<ServerRequestCloseListener> listenersClose() |
| 192 => new _NativeListPrimitiveElement<ServerRequestCloseListener>( |
| 193 _listeners('close')); |
| 194 |
| 195 final String method; |
| 196 final String url; |
| 197 Map<String, String> get headers() |
| 198 => new _NativeMapPrimitiveValue<String>(_headers()); |
| 199 var _headers() native "return this.headers;"; |
| 200 final String httpVersion; |
| 201 |
| 202 void setEncoding([String encoding]) native; |
| 203 void pause() native; |
| 204 void resume() native; |
| 205 net.Socket connection; |
| 206 } |
| 207 |
| 208 class ServerResponse implements WritableStream native "http.ServerResponse" { |
| 209 // EventEmitter |
| 210 void removeAllListeners(String event) |
| 211 native "this._writeStream.removeAllListeners(event);"; |
| 212 void setMaxListeners(num n) native; |
| 213 var _listeners(String key) |
| 214 native "return this.listeners(key);"; |
| 215 |
| 216 // CommonStream |
| 217 |
| 218 // Error event |
| 219 void emitError(Error error) |
| 220 native "this.emit('error', error);"; |
| 221 void addListenerError(StreamErrorListener listener) |
| 222 native "this.addListener('error', listener);"; |
| 223 void onError(StreamErrorListener listener) |
| 224 native "this.on('error', listener);"; |
| 225 void onceError(StreamErrorListener listener) |
| 226 native "this.once('error', listener);"; |
| 227 void removeListenerError(StreamErrorListener listener) |
| 228 native "this.removeListener('error', listener);"; |
| 229 List<StreamErrorListener> listenersError() |
| 230 => new _NativeListPrimitiveElement<StreamErrorListener>(_listeners( |
| 231 'error')); |
| 232 |
| 233 // Close event |
| 234 void emitClose() |
| 235 native "this.emit('close');"; |
| 236 void addListenerClose(StreamCloseListener listener) |
| 237 native "this.addListener('close', listener);"; |
| 238 void onClose(StreamCloseListener listener) |
| 239 native "this.on('close', listener);"; |
| 240 void onceClose(StreamCloseListener listener) |
| 241 native "this.once('close', listener);"; |
| 242 void removeListenerClose(StreamCloseListener listener) |
| 243 native "this.removeListener('close', listener);"; |
| 244 List<StreamCloseListener> listenersClose() |
| 245 => new _NativeListPrimitiveElement<StreamCloseListener>(_listeners( |
| 246 'close')); |
| 247 |
| 248 // WritableStream |
| 249 |
| 250 // Drain event |
| 251 void emitDrain() |
| 252 native "this.emit('drain');"; |
| 253 void addListenerDrain(WritableStreamDrainListener listener) |
| 254 native "this.addListener('drain', listener);"; |
| 255 void onDrain(WritableStreamDrainListener listener) |
| 256 native "this.on('drain', listener);"; |
| 257 void onceDrain(WritableStreamDrainListener listener) |
| 258 native "this.once('drain', listener);"; |
| 259 void removeListenerDrain(WritableStreamDrainListener listener) |
| 260 native "this.removeListener('drain', listener);"; |
| 261 List<WritableStreamDrainListener> listenersDrain() |
| 262 => new _NativeListPrimitiveElement<WritableStreamDrainListener>(_listeners( |
| 263 'drain')); |
| 264 |
| 265 // Pipe event |
| 266 void emitPipe(ReadableStream src) |
| 267 native "this.emit('pipe', src);"; |
| 268 void addListenerPipe(WritableStreamPipeListener listener) |
| 269 native "this.addListener('pipe', listener);"; |
| 270 void onPipe(WritableStreamPipeListener listener) |
| 271 native "this.on('pipe', listener);"; |
| 272 void oncePipe(WritableStreamPipeListener listener) |
| 273 native "this.once('pipe', listener);"; |
| 274 void removeListenerPipe(WritableStreamPipeListener listener) |
| 275 native "this.removeListener('pipe', listener);"; |
| 276 List<WritableStreamPipeListener> listenersPipe() |
| 277 => new _NativeListPrimitiveElement<WritableStreamPipeListener>(_listeners( |
| 278 'pipe')); |
| 279 |
| 280 |
| 281 void writeContinue() native; |
| 282 void writeHead(int statusCode, [String reasonPhrase, Map<String,String> |
| 283 headers]) |
| 284 native; |
| 285 int statusCode; |
| 286 void setHeader(String name, String value) native; |
| 287 String getHeader(String name) native; |
| 288 void removeHeader(String name) native; |
| 289 |
| 290 |
| 291 void write(String data, [String encoding = 'utf8']) native; |
| 292 void writeBuffer(Buffer data) |
| 293 native "this.write(data);"; |
| 294 |
| 295 void addTrailers(Map<String,String> headers) native; |
| 296 |
| 297 void end([String data, String encoding = 'utf8']) native; |
| 298 } |
| 299 |
| 300 class Agent native "require('http').Agent" { |
| 301 int maxSockets; |
| 302 } |
| 303 |
| 304 typedef void ClientRequestResponseListener(ClientResponse response); |
| 305 typedef void ClientRequestSocketListener(net.Socket socket); |
| 306 typedef void ClientRequestUpgradeListener( |
| 307 ClientResponse response, net.Socket socket, Buffer head); |
| 308 typedef void ClientRequestContinueListener(); |
| 309 |
| 310 class ClientRequest implements WritableStream native |
| 311 "require('http').ClientRequest" { |
| 312 // EventEmitter |
| 313 void removeAllListeners(String event) |
| 314 native "this._writeStream.removeAllListeners(event);"; |
| 315 void setMaxListeners(num n) native; |
| 316 var _listeners(String key) |
| 317 native "return this.listeners(key);"; |
| 318 |
| 319 // CommonStream |
| 320 |
| 321 // Error event |
| 322 void emitError(Error error) |
| 323 native "this.emit('error', error);"; |
| 324 void addListenerError(StreamErrorListener listener) |
| 325 native "this.addListener('error', listener);"; |
| 326 void onError(StreamErrorListener listener) |
| 327 native "this.on('error', listener);"; |
| 328 void onceError(StreamErrorListener listener) |
| 329 native "this.once('error', listener);"; |
| 330 void removeListenerError(StreamErrorListener listener) |
| 331 native "this.removeListener('error', listener);"; |
| 332 List<StreamErrorListener> listenersError() |
| 333 => new _NativeListPrimitiveElement<StreamErrorListener>(_listeners( |
| 334 'error')); |
| 335 |
| 336 // Close event |
| 337 void emitClose() |
| 338 native "this.emit('close');"; |
| 339 void addListenerClose(StreamCloseListener listener) |
| 340 native "this.addListener('close', listener);"; |
| 341 void onClose(StreamCloseListener listener) |
| 342 native "this.on('close', listener);"; |
| 343 void onceClose(StreamCloseListener listener) |
| 344 native "this.once('close', listener);"; |
| 345 void removeListenerClose(StreamCloseListener listener) |
| 346 native "this.removeListener('close', listener);"; |
| 347 List<StreamCloseListener> listenersClose() |
| 348 => new _NativeListPrimitiveElement<StreamCloseListener>(_listeners( |
| 349 'close')); |
| 350 |
| 351 // WritableStream |
| 352 |
| 353 // Drain event |
| 354 void emitDrain() |
| 355 native "this.emit('drain');"; |
| 356 void addListenerDrain(WritableStreamDrainListener listener) |
| 357 native "this.addListener('drain', listener);"; |
| 358 void onDrain(WritableStreamDrainListener listener) |
| 359 native "this.on('drain', listener);"; |
| 360 void onceDrain(WritableStreamDrainListener listener) |
| 361 native "this.once('drain', listener);"; |
| 362 void removeListenerDrain(WritableStreamDrainListener listener) |
| 363 native "this.removeListener('drain', listener);"; |
| 364 List<WritableStreamDrainListener> listenersDrain() |
| 365 => new _NativeListPrimitiveElement<WritableStreamDrainListener>(_listeners( |
| 366 'drain')); |
| 367 |
| 368 // Pipe event |
| 369 void emitPipe(ReadableStream src) |
| 370 native "this.emit('pipe', src);"; |
| 371 void addListenerPipe(WritableStreamPipeListener listener) |
| 372 native "this.addListener('pipe', listener);"; |
| 373 void onPipe(WritableStreamPipeListener listener) |
| 374 native "this.on('pipe', listener);"; |
| 375 void oncePipe(WritableStreamPipeListener listener) |
| 376 native "this.once('pipe', listener);"; |
| 377 void removeListenerPipe(WritableStreamPipeListener listener) |
| 378 native "this.removeListener('pipe', listener);"; |
| 379 List<WritableStreamPipeListener> listenersPipe() |
| 380 => new _NativeListPrimitiveElement<WritableStreamPipeListener>(_listeners( |
| 381 'pipe')); |
| 382 |
| 383 |
| 384 // ClientRequest specific events |
| 385 |
| 386 // response event |
| 387 void emitResponse(ClientResponse response) |
| 388 native "this.emit('response');"; |
| 389 void addListenerResponse(ClientRequestResponseListener listener) |
| 390 native "this.addListener('response', listener);"; |
| 391 void onResponse(ClientRequestResponseListener listener) |
| 392 native "this.on('response', listener);"; |
| 393 void onceResponse(ClientRequestResponseListener listener) |
| 394 native "this.once('response', listener);"; |
| 395 void removeListenerResponse(ClientRequestResponseListener listener) |
| 396 native "this.removeListener('response', listener);"; |
| 397 List<ClientRequestResponseListener> listenersResponse() |
| 398 => new _NativeListPrimitiveElement<ClientRequestResponseListener>( |
| 399 _listeners('response')); |
| 400 |
| 401 // socket event |
| 402 void emitSocket(net.Socket socket) |
| 403 native "this.emit('socket');"; |
| 404 void addListenerSocket(ClientRequestSocketListener listener) |
| 405 native "this.addListener('socket', listener);"; |
| 406 void onSocket(ClientRequestSocketListener listener) |
| 407 native "this.on('socket', listener);"; |
| 408 void onceSocket(ClientRequestSocketListener listener) |
| 409 native "this.once('socket', listener);"; |
| 410 void removeListenerSocket(ClientRequestSocketListener listener) |
| 411 native "this.removeListener('socket', listener);"; |
| 412 List<ClientRequestSocketListener> listenersSocket() |
| 413 => new _NativeListPrimitiveElement<ClientRequestSocketListener>( |
| 414 _listeners('socket')); |
| 415 |
| 416 // upgrade event |
| 417 void emitUpgrade(ClientResponse response, net.Socket socket, Buffer head) |
| 418 native "this.emit('upgrade');"; |
| 419 void addListenerUpgrade(ClientRequestUpgradeListener listener) |
| 420 native "this.addListener('upgrade', listener);"; |
| 421 void onUpgrade(ClientRequestUpgradeListener listener) |
| 422 native "this.on('upgrade', listener);"; |
| 423 void onceUpgrade(ClientRequestUpgradeListener listener) |
| 424 native "this.once('upgrade', listener);"; |
| 425 void removeListenerUpgrade(ClientRequestUpgradeListener listener) |
| 426 native "this.removeListener('upgrade', listener);"; |
| 427 List<ClientRequestUpgradeListener> listenersUpgrade() |
| 428 => new _NativeListPrimitiveElement<ClientRequestUpgradeListener>( |
| 429 _listeners('upgrade')); |
| 430 |
| 431 // continue event |
| 432 void emitContinue() |
| 433 native "this.emit('continue');"; |
| 434 void addListenerContinue(ClientRequestContinueListener listener) |
| 435 native "this.addListener('continue', listener);"; |
| 436 void onContinue(ClientRequestContinueListener listener) |
| 437 native "this.on('continue', listener);"; |
| 438 void onceContinue(ClientRequestContinueListener listener) |
| 439 native "this.once('continue', listener);"; |
| 440 void removeListenerContinue(ClientRequestContinueListener listener) |
| 441 native "this.removeListener('continue', listener);"; |
| 442 List<ClientRequestContinueListener> listenersContinue() |
| 443 => new _NativeListPrimitiveElement<ClientRequestContinueListener>( |
| 444 _listeners('continue')); |
| 445 |
| 446 // WritableStream methods and instance variables |
| 447 |
| 448 bool writable; |
| 449 bool write(String string, [String encoding='utf8', int fd]) native; |
| 450 bool writeBuffer(Buffer buffer) native; |
| 451 void end([String string, String encoding]) native; |
| 452 void endBuffer(Buffer buffer) native "this.end(buffer);"; |
| 453 void destroy() native; |
| 454 void destroySoon() native; |
| 455 |
| 456 // ClientRequest methods |
| 457 void abort() native; |
| 458 void setTimeout(int timeout, void callback()) native; |
| 459 void setNoDelay([bool noDelay]) native; |
| 460 void setSocketKeepAlive([bool enable, int initialDelay]) native; |
| 461 } |
| 462 |
| 463 class ClientResponse implements ReadableStream native |
| 464 "require('http').ClientResponse" { |
| 465 // EventEmitter |
| 466 void removeAllListeners(String event) native; |
| 467 void setMaxListeners(num n) native; |
| 468 var _listeners(String key) |
| 469 native "return this.listeners(key);"; |
| 470 |
| 471 // CommonStream |
| 472 |
| 473 // Error event |
| 474 void emitError(Error error) |
| 475 native "this.emit('error', error);"; |
| 476 void addListenerError(StreamErrorListener listener) |
| 477 native "this.addListener('error', listener);"; |
| 478 void onError(StreamErrorListener listener) |
| 479 native "this.on('error', listener);"; |
| 480 void onceError(StreamErrorListener listener) |
| 481 native "this.once('error', listener);"; |
| 482 void removeListenerError(StreamErrorListener listener) |
| 483 native "this.removeListener('error', listener);"; |
| 484 List<StreamErrorListener> listenersError() |
| 485 => new _NativeListPrimitiveElement<StreamErrorListener>(_listeners( |
| 486 'error')); |
| 487 |
| 488 // Close event |
| 489 void emitClose() |
| 490 native "this.emit('close');"; |
| 491 void addListenerClose(StreamCloseListener listener) |
| 492 native "this.addListener('close', listener);"; |
| 493 void onClose(StreamCloseListener listener) |
| 494 native "this.on('close', listener);"; |
| 495 void onceClose(StreamCloseListener listener) |
| 496 native "this.once('close', listener);"; |
| 497 void removeListenerClose(StreamCloseListener listener) |
| 498 native "this.removeListener('close', listener);"; |
| 499 List<StreamCloseListener> listenersClose() |
| 500 => new _NativeListPrimitiveElement<StreamCloseListener>(_listeners( |
| 501 'close')); |
| 502 |
| 503 // ReadableStream |
| 504 |
| 505 // Data event |
| 506 void emitData(var data) |
| 507 native "this.emit('data', data);"; |
| 508 void addListenerData(ReadableStreamDataListener listener) |
| 509 native "this.addListener('data', listener);"; |
| 510 void onData(ReadableStreamDataListener listener) |
| 511 native "this.on('data', listener);"; |
| 512 void onceData(ReadableStreamDataListener listener) |
| 513 native "this.once('data', listener);"; |
| 514 void removeListenerData(ReadableStreamDataListener listener) |
| 515 native "this.removeListener('data', listener);"; |
| 516 List<ReadableStreamDataListener> listenerData() |
| 517 => new _NativeListPrimitiveElement<ReadableStreamDataListener>(_listeners( |
| 518 'data')); |
| 519 |
| 520 // End event |
| 521 void emitEnd() |
| 522 native "this.emit('end');"; |
| 523 void addListenerEnd(ReadableStreamEndListener listener) |
| 524 native "this.addListener('end', listener);"; |
| 525 void onEnd(ReadableStreamEndListener listener) |
| 526 native "this.on('end', listener);"; |
| 527 void onceEnd(ReadableStreamEndListener listener) |
| 528 native "this.once('end', listener);"; |
| 529 void removeListenerEnd(ReadableStreamEndListener listener) |
| 530 native "this.removeListener('end', listener);"; |
| 531 List<ReadableStreamEndListener> listenersEnd() |
| 532 => new _NativeListPrimitiveElement<ReadableStreamEndListener>(_listeners( |
| 533 'end')); |
| 534 |
| 535 // ReadableStream methods and instance variables |
| 536 |
| 537 bool readable; |
| 538 void setEncoding(String encoding) native; |
| 539 void pause() native; |
| 540 void resume() native; |
| 541 void destroy() native; |
| 542 void destroySoon() native; |
| 543 WritableStream pipe(WritableStream destination, [Map options]) native; |
| 544 |
| 545 // class specific methods and instance variables |
| 546 int statusCode; |
| 547 String httpVersion; |
| 548 int httpVersionMajor; |
| 549 int httpVersionMinor; |
| 550 Map<String, String> get headers() |
| 551 => new _NativeMapPrimitiveValue<String>(_headers()); |
| 552 var _headers() native "return this.headers;"; |
| 553 Map<String, String> trailers() |
| 554 => new _NativeMapPrimitiveValue<String>(_trailers()); |
| 555 var _trailers() native "return this.trailers;"; |
| 556 } |
OLD | NEW |