Commit Graph

211 Commits

Author SHA1 Message Date
sgjesse@google.com 8a2a138ed2 Detect EOF when reading stdio from terminal on Mac OS
R=ajohnsen@google.com
BUG=http://dartbug.com/453

patch from issue 17381012

Review URL: https://codereview.chromium.org//17463003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24397 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-25 11:47:55 +00:00
ajohnsen@google.com 3ad9779be6 Add reverse dns lookup as a method on InternetAddress.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//17640008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24393 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-25 11:27:48 +00:00
ajohnsen@google.com 4624420914 Add NetworkAdaptor to dart:io.
NetworkAdaptor contains a static method, list, that will query the
underlaying system for active network adaptors.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//16514010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24267 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-21 07:58:48 +00:00
sgjesse@google.com 54f6939ffc Ensure that there is no "hidden" DNS lookup in secure socket code
The required setting of the internet adddress of the peer for NSS is
now using the internet address which have already been looked up in
Dart code for normal secure socket connect.

In the cases where SecureSocket.secure and RawSecureSocket.secure is
used with a host name, the internet address of the already connected
socket will be used. If that is not sufficient an IntetnetAddress from
DNS lookup in Dart can be passed instead of just a host name.

R=ajohnsen@google.com, whesse@google.com
BUG=http://dartbug.com/11103

Review URL: https://codereview.chromium.org//17381012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24174 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-19 09:07:43 +00:00
sgjesse@google.com 55709f1f43 Ensure that only byte values are sent by sockets and web sockets
R=ajohnsen@google.com
BUG=http://dartbug.com/11007

Review URL: https://codereview.chromium.org//16363005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23896 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-12 08:33:16 +00:00
ajohnsen@google.com 5ce3b9ddea Clean up dart:io exceptions.
- Introduce IOException.
- Remove HttpParserException.
- Merge RedirectLimitExceededException and RedirectLoopException into
RedirectException.
- Remove 'IO' from FileIOException, DirectoryIOException, LinkIOException
and SocketIOException.

BUG=https://code.google.com/p/dart/issues/detail?id=9955
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//16123036

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23848 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-11 13:15:46 +00:00
lrn@google.com faa7227cec Make new StreamController be async by default.
Change all instances, except some tests, to be sync still.
Rename Multiplex to Broadcast everywhere.

R=floitsch@google.com

Review URL: https://codereview.chromium.org//16125005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23453 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-31 06:07:39 +00:00
lrn@google.com 39c8f31441 Make new StreamController().isPaused be true until the first listener arrives.
This is compatible with what we had before, and makes good sense if you read
"isPaused" as "must buffer incoming events".

R=floitsch@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//15981003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23318 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-29 05:39:23 +00:00
lrn@google.com 781e84284f Reapply "Active stream subscriptions".
Makes subscriptions the active part of a stream, with the stream
itself being just an inert creator of subscriptions.

This changes the behavior of a "single subscription" stream to match
the documentation: After the subscription is canceled, you can't
resubscribe to the stream. Previously, you could do that, but it was
never documented or intended.
This also makes the stream of a StreamController not be paused while
before it's subscribed - it is always the subscription that is paused
or not, and while there is no subscription, the stream cannot be
paused. Previously the stream was set to paused until the first
subscription in order to prevent events from being lost. That is
handled independently of pauses now.

Adds StreamController.multiplex constructor. This name is tentative,
and likely to change. Its behavior may change as well. It currently
provides a new single-subscription stream each time its "stream"
getter is read, and you can subscribe to these.

Adds StreamIterator class that allows iterating over a stream's data
events using (async) "moveNext()" and "current", like a direct style
Iterator (sorry, it won't work in a for-in loop).

Review URL: https://codereview.chromium.org//16131003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23237 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-28 07:28:36 +00:00
lrn@google.com cc0d9d57af Revert until Windows crash is debugged.
Reverts r23218, r23217, r23208, r23207, r23206, r23205, r23204.

r23218 | Path observer is listened more than once, so make it multiplex.
r23217 | Add StreamController.multiplex constructor.
r23208 | Fix bug in streamimpl
r23207 | Fix bug in stream iterator.
r23206 | Change expectations for http_parser_test.
r23205 | Fix bug in stream-impl.
r23204 | Make StreamSubscription be the active part of a string.

Review URL: https://codereview.chromium.org//15989006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23221 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-27 13:03:03 +00:00
lrn@google.com ee1c11a2a6 Make StreamSubscription be the active part of a string.
It is the one keeping the buffer of events, not the stream.

R=ajohnsen@google.com, floitsch@google.com, jmesserly@google.com

Review URL: https://codereview.chromium.org//14753009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23204 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-27 08:34:20 +00:00
asiva@google.com 1792aa6bf3 Change SecureSocket to use a single patch class instead of multiple patch classes the way it is being done now.
R=ager@google.com

Review URL: https://codereview.chromium.org//15899003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23087 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-23 17:54:32 +00:00
ajohnsen@google.com f06faf4a48 Remove explicit delayed futures in dart:io.
After the change of Completers always being delayed to the next tick,
      this is no longer needed.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//15680002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22984 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-22 07:23:18 +00:00
ajohnsen@google.com 6a78c0c0b8 Add v6Only named argument to ServerSocket and etc.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//14766003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22309 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-02 11:23:40 +00:00
ajohnsen@google.com a516bbc22d Enable IPv6 by default in dart:io.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//14766004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22240 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-01 12:18:53 +00:00
sgjesse@google.com 2fdb878ebe Change the signature for all network bind calls.
All the bind calls on RawServerSocket, ServerSocket,
RawSecureServerSocket, SecureServerSocket and HttpServer (and
bindSecure on HttpServer) now have mandatory address and port
parameters. All the rest of the parameters are named optional
(including backlog).

The address parameter can be an InternetAddress or a String for all
these calls.

R=ajohnsen@google.com, whesse@google.com
BUG=

Review URL: https://codereview.chromium.org//14640008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22227 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-01 09:14:04 +00:00
sgjesse@google.com 6c486c72cd Add static getters for common internet addresses
R=whesse@google.com
BUG=

Review URL: https://codereview.chromium.org//14619008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22174 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-30 11:30:05 +00:00
ajohnsen@google.com ca706b0387 Disable IPv6 lookup by default.
Will revert once IPv6 have stablized.

BUG=

Review URL: https://codereview.chromium.org//13918013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21936 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 10:25:25 +00:00
ajohnsen@google.com 55963a1a6d Add new InternetAddress class with a static lookup function (including IPv6
results).

Reapply of https://codereview.chromium.org/13880029/ with fixes.

BUG=

Review URL: https://codereview.chromium.org//14469002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21934 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 09:26:58 +00:00
ajohnsen@google.com 60946b53fc Revert "Add new InternetAddress class with a static lookup function (including IPv6 results)."
Revert "Attempt to fix strict align issue."
Revert "Trying another fix."

BUG=

Review URL: https://codereview.chromium.org//14036017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21928 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 08:10:00 +00:00
ajohnsen@google.com 20d1f5ddda Add new InternetAddress class with a static lookup function (including IPv6 results).
Reapply of https://codereview.chromium.org/14083007/ with fixes.

BUG=

Review URL: https://codereview.chromium.org//13880029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21923 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 07:12:05 +00:00
sgjesse@google.com afcb3ce69e Revert "Add new InternetAddress class with a static lookup function (including IPv6 results)"
TBR=ajohnsen@google.com

Review URL: https://codereview.chromium.org//14081024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21865 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 10:07:03 +00:00
ajohnsen@google.com b33d142414 Add new InternetAddress class with a static lookup function (including IPv6 results).
Socket.connect/ServerSocket.bind now accepts IPv6 host names. If a new ServerSocket is connected to an IPv6 interface, it will (if possible) support incoming IPv4 connections as well.

BUG=

Review URL: https://codereview.chromium.org//14083007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21862 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 09:36:18 +00:00
sgjesse@google.com efcd056ebe Support upgrading sockets to secure sockets
This build on the support for upgrading raw sockets to raw secure sockets.

R=ajohnsen@google.com
BUG=https://code.google.com/p/dart/issues/detail?id=8789

Review URL: https://codereview.chromium.org//14034012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21859 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 06:50:59 +00:00
sgjesse@google.com e1aa202b58 Add the ability to secure an already established raw socket connection
The static methods secure and secureServer can be used to start
TLS handshake as eihter client or server.

This CL only implement the securing of RawSocket.

This also changes the semantics of cancelling a subscription on a
RawSocket from closing the socket to just pausing.

R=ager@google.com

BUG=https://code.google.com/p/dart/issues/detail?id=8789

Review URL: https://codereview.chromium.org//13502004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21719 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-19 07:37:37 +00:00
floitsch@google.com 466d6670c1 Refactor Future constructors.
BUG=

Review URL: https://codereview.chromium.org//14070010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21517 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 21:24:27 +00:00
floitsch@google.com 5431a5af54 Remove AsyncError with Expando.
Review URL: https://codereview.chromium.org//14251006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21498 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 18:58:32 +00:00
floitsch@google.com f553392322 Change StreamController constructor.
Review URL: https://codereview.chromium.org//14196003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21472 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 16:34:26 +00:00
floitsch@google.com e2ee353940 Rename unsubscribeOnError to cancelOnError.
Review URL: https://codereview.chromium.org//14251013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21469 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 16:07:36 +00:00
ajohnsen@google.com b4eacbf8aa Rename RandomAccessFile.readList and RandomAccessFile.writeList to RandomAccessFile.readInto and RandomAccessFile.writeFrom.
BUG=

Review URL: https://codereview.chromium.org//14018007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21466 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 15:44:41 +00:00
ajohnsen@google.com 67650cb16e Remove .writeStream, .consume and rewrite IOSink to correctly implement a (sane) well-defined behaviour of the .done future.
BUG=

Review URL: https://codereview.chromium.org//14028017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21416 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 07:35:45 +00:00
floitsch@google.com 285849c801 Change hasSubscribers to hasListener.
Review URL: https://codereview.chromium.org//14103010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21337 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-12 09:30:05 +00:00
floitsch@google.com 134302aa48 Remove second generic argument of StreamConsumer.
Review URL: https://codereview.chromium.org//14172013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21303 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 18:11:40 +00:00
ajohnsen@google.com dcaf52732e Remove StreamSink(replaced by EventSink) and make IOSink extend EventSink.
With this change 'writeBytes' was renamed to 'add'.

BUG=

Review URL: https://codereview.chromium.org//14150002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21275 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 12:54:19 +00:00
ajohnsen@google.com 140409a05a Wrap stdout/stderr/stdin to only expose the relevant methods.
BUG=https://code.google.com/p/dart/issues/detail?id=9439,https://code.google.com/p/dart/issues/detail?id=9593

Review URL: https://codereview.chromium.org//13787003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21063 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-08 12:13:03 +00:00
floitsch@google.com e72250e49b StreamConsumer has an addStream and a close functions.
The 'consume' function will be removed.

Review URL: https://codereview.chromium.org//13680002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20979 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-05 16:22:11 +00:00
floitsch@google.com f85fa4feff Make argument to StringSink.writeln optional.
BUG= http://dartbug.com/9102

Review URL: https://codereview.chromium.org//12870003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20074 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-15 12:45:40 +00:00
ajohnsen@google.com fb53f40e65 Add setOption method on Socket/RawSocket.
This will allow the user to enable TCP_NODELAY on the native sockets.

BUG=

Review URL: https://codereview.chromium.org//12614014

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20014 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-14 12:46:54 +00:00
sgjesse@google.com a429f3aa83 Fix checked mode error on socket IOSink
The set encoding method on a Sockets IOSink implementation failed in
checked mode. Added a test calling all IOSink methods on a socket.

BUG=https://code.google.com/p/dart/issues/detail?id=9020

R=ajohnsen@google.com

Review URL: https://codereview.chromium.org//12408004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19803 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-11 16:15:56 +00:00
lrn@google.com bead146749 Renamed StreamSink to EventSink. Renamed signalError to addError.
Review URL: https://codereview.chromium.org//12610006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19683 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-08 11:31:19 +00:00
sgjesse@google.com b6096848b1 Make IOSink implement StringSink
Besides adding the StringSink methods I also added writeBytes and
deprecated both add and addString.

To handle the encoding of strings the IOSike has an encoding
property. This property is mutable in situation when it makes sense to
change encoding of what is written. The exception here is for HTTP
where the encoding is determined from the header and the encoding
cannot be changed.

R=ajohnsen@google.com, ager@google.com, nweiz@google.com

BUG=

Review URL: https://codereview.chromium.org//12504006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19676 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-08 10:06:28 +00:00
whesse@google.com 8929d6c037 dart:io | Fix a crash when read was called on a closed socket on Windows.
BUG=dartbug.com/8798

Review URL: https://codereview.chromium.org//12395017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19396 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-04 16:16:18 +00:00
ajohnsen@google.com ba01a8ecfc Fix socket so we stop the consumer before we close the socket - this makes sure we socket-close future don't result in a socket write.
BUG=https://code.google.com/p/dart/issues/detail?id=8874

Review URL: https://codereview.chromium.org//12393010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19316 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-01 14:20:38 +00:00
sgjesse@google.com 7d6ddd4ae9 Remove wrong type annotation
nativeCreateConnect returns either a bool (only true) or an OSError.

TBR=ajohnsen@google.com

BUG=

Review URL: https://codereview.chromium.org//12383043

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19276 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-01 07:53:11 +00:00
ajohnsen@google.com b6f9a3e395 Correctly close done future with an error, before a normal complete can happen.
BUG=

Review URL: https://codereview.chromium.org//12387014

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19229 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-28 14:16:05 +00:00
ajohnsen@google.com f5ade02146 Make sure the socket unsubscribes on error, so we don't get race conditions between an error and an immidiately following close event.
This makes sure we always see the expected errors.

BUG=

Review URL: https://codereview.chromium.org//12314148

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19117 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 09:27:01 +00:00
lrn@google.com 6b4f4b1bab Change new List(n) to return fixed length list.
Deprecate List.fixedLength, add List.filled.

Make Iterable.toList and List.from take "growable" argument,
defaulting to false.

Review URL: https://codereview.chromium.org//12328104

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19112 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 08:45:04 +00:00
ajohnsen@google.com 7912f3f1bd Rewrite the Future-pipeline from the Socket to the HttpClientRequest/HttpResponse.
Before we had two future, HttpClientRequest/HttpResponse.done and
Socket.addStream's return valud(stored as _writeDoneFuture in
    http_impl). Many issues in our code was based on the futures not
being the same, that the user will get a done event, while the socket is
still writing data on the socket.

Immidiate calls to HttpServer/HttpClient.close, after e.g. pipe, would
then destroy the socket while still having data in dart buffers.

The new approach makes sure that there is a direct future link between
the socket and the user.

BUG=

Review URL: https://codereview.chromium.org//12328114

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19111 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 08:27:12 +00:00
whesse@google.com 77a1a0c56a dart:io | Fix writing to a Socket while and after calling destroy() on it.
BUG=dartbug.com/8681
TEST=standalone/io/http_client_request_test

Review URL: https://codereview.chromium.org//12330109

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18969 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-25 14:52:39 +00:00
ajohnsen@google.com 167394115a Don't send null data events on a Socket stream.
BUG=

Review URL: https://codereview.chromium.org//12334035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18877 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-22 11:24:35 +00:00