Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Issue 9495007: Prepare the HTTP library for inclusion in the standalone VM (step 2) (Closed)

Created:
8 years, 9 months ago by Søren Gjesse
Modified:
8 years, 9 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Prepare the HTTP library for inclusion in the standalone VM (step 2) Change the handling of the received data on HTTPRequest and HTTPClientResponse to use the InputStream interface instead of dataReceived and dataEnd handlers. We should probably do something to make the following serer side and client side patterns simpler: void handler(HTTPRequest request, HTTPResponse response) { ... StringBuffer body = new StringBuffer(); StringInputStream input = new StringInputStream(request.inputStream); input.dataHandler = () => body.add(input.read()); input.closeHandler = () { String data = body.toString(); ... } } HTTPClientConnection conn = ... conn.responseHandler = (HTTPClientResponse r) { ... StringBuffer body = new StringBuffer(); StringInputStream input = new StringInputStream(request.inputStream); input.dataHandler = () => body.add(input.read()); input.closeHandler = () { String data = body.toString(); ... } } R=ager@google.com,ajohnsen@google.com BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=4679

Patch Set 1 #

Total comments: 23

Patch Set 2 : Update http.dart with the changed interface and fix type error #

Patch Set 3 : Addressed review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+529 lines, -355 lines) Patch
M runtime/bin/buffer_list.dart View 1 chunk +4 lines, -0 lines 0 comments Download
M runtime/bin/stream_util.dart View 1 2 3 chunks +33 lines, -6 lines 0 comments Download
M samples/chat/chat_server_lib.dart View 13 chunks +67 lines, -66 lines 0 comments Download
M samples/chat/chat_stress_client.dart View 1 2 6 chunks +33 lines, -26 lines 0 comments Download
M samples/chat/dart_client/chat.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M samples/chat/http.dart View 1 3 chunks +8 lines, -26 lines 0 comments Download
M samples/chat/http_impl.dart View 1 2 22 chunks +205 lines, -179 lines 0 comments Download
M samples/tests/samples/src/chat/ChatServerTest.dart View 7 chunks +46 lines, -35 lines 0 comments Download
M samples/tests/samples/src/chat/HttpTest.dart View 1 2 11 chunks +131 lines, -15 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Søren Gjesse
8 years, 9 months ago (2012-02-28 11:54:56 UTC) #1
Anders Johnsen
LGTM, I really like the new streams! http://codereview.chromium.org/9495007/diff/1/samples/chat/chat_server_lib.dart File samples/chat/chat_server_lib.dart (right): http://codereview.chromium.org/9495007/diff/1/samples/chat/chat_server_lib.dart#newcode411 samples/chat/chat_server_lib.dart:411: StringBuffer body ...
8 years, 9 months ago (2012-02-28 12:23:40 UTC) #2
Mads Ager (google)
lgtm http://codereview.chromium.org/9495007/diff/1/runtime/bin/stream_util.dart File runtime/bin/stream_util.dart (right): http://codereview.chromium.org/9495007/diff/1/runtime/bin/stream_util.dart#newcode63 runtime/bin/stream_util.dart:63: // More data have been received asynchronously. Perform ...
8 years, 9 months ago (2012-02-28 12:27:39 UTC) #3
Søren Gjesse
8 years, 9 months ago (2012-02-28 13:03:42 UTC) #4
Also fixed the HTTPOutputStream to return booleand on write anf writeFrom to
make it complient with the interface definition - required for piping.

http://codereview.chromium.org/9495007/diff/1/runtime/bin/stream_util.dart
File runtime/bin/stream_util.dart (right):

http://codereview.chromium.org/9495007/diff/1/runtime/bin/stream_util.dart#ne...
runtime/bin/stream_util.dart:63: // More data have been received asynchronously.
Perform the data
On 2012/02/28 12:27:40, Mads Ager wrote:
> have -> has

Done.

http://codereview.chromium.org/9495007/diff/1/runtime/bin/stream_util.dart#ne...
runtime/bin/stream_util.dart:73: // Close indication have been received
asynchronously. Perform the
On 2012/02/28 12:27:40, Mads Ager wrote:
> have -> has

Done.

http://codereview.chromium.org/9495007/diff/1/samples/chat/chat_server_lib.dart
File samples/chat/chat_server_lib.dart (right):

http://codereview.chromium.org/9495007/diff/1/samples/chat/chat_server_lib.da...
samples/chat/chat_server_lib.dart:411: StringBuffer body = new StringBuffer();
On 2012/02/28 12:23:40, ajohnsen wrote:
> It could be nice to have a StringBuffer.fromStream(...). The problem is
however,
> that they reside in two different libs. Could we have an
> InputStream.toStringBuffer?

As discussed offline I will add a simple way to get all data in one callback.

http://codereview.chromium.org/9495007/diff/1/samples/chat/chat_stress_client...
File samples/chat/chat_stress_client.dart (right):

http://codereview.chromium.org/9495007/diff/1/samples/chat/chat_stress_client...
samples/chat/chat_stress_client.dart:66: stream.closeHandler = () =>
leaveResponseHandler(response,
On 2012/02/28 12:27:40, Mads Ager wrote:
> Maybe either move the whole body to the next line or even use {}?
> 
> Ditto for all occurrences below.

Done (using {} that is).

http://codereview.chromium.org/9495007/diff/1/samples/chat/http.dart
File samples/chat/http.dart (right):

http://codereview.chromium.org/9495007/diff/1/samples/chat/http.dart#newcode8
samples/chat/http.dart:8: #source("../../runtime/bin/buffer_list.dart");
On 2012/02/28 12:23:40, ajohnsen wrote:
> We don't expose these in dart:io?

No, they only contains private classes. When this is moved to dart:io these
#source statements can go away.

http://codereview.chromium.org/9495007/diff/1/samples/chat/http_impl.dart
File samples/chat/http_impl.dart (right):

http://codereview.chromium.org/9495007/diff/1/samples/chat/http_impl.dart#new...
samples/chat/http_impl.dart:632: * Delegate functions for the HTTPInputStream
implementation.
On 2012/02/28 12:27:40, Mads Ager wrote:
> Just use '//' style comment?

Done.

http://codereview.chromium.org/9495007/diff/1/samples/chat/http_impl.dart#new...
samples/chat/http_impl.dart:1256: * Delegate functions for the HTTPInputStream
implementation.
On 2012/02/28 12:27:40, Mads Ager wrote:
> Maybe just use '//' comment.

Done.

http://codereview.chromium.org/9495007/diff/1/samples/tests/samples/src/chat/...
File samples/tests/samples/src/chat/HttpTest.dart (right):

http://codereview.chromium.org/9495007/diff/1/samples/tests/samples/src/chat/...
samples/tests/samples/src/chat/HttpTest.dart:98: InputStream input =
request.inputStream;
On 2012/02/28 12:27:40, Mads Ager wrote:
> Use pipe?

Done.

http://codereview.chromium.org/9495007/diff/1/samples/tests/samples/src/chat/...
samples/tests/samples/src/chat/HttpTest.dart:98: InputStream input =
request.inputStream;
On 2012/02/28 12:23:40, ajohnsen wrote:
> Can we pipe this?

Done.

http://codereview.chromium.org/9495007/diff/1/samples/tests/samples/src/chat/...
samples/tests/samples/src/chat/HttpTest.dart:98: InputStream input =
request.inputStream;
On 2012/02/28 12:23:40, ajohnsen wrote:
> Can we pipe this?

Done.

http://codereview.chromium.org/9495007/diff/1/samples/tests/samples/src/chat/...
samples/tests/samples/src/chat/HttpTest.dart:149: _chunkedEncoding = true;
On 2012/02/28 12:23:40, ajohnsen wrote:
> Indentation. 

Done.

Powered by Google App Engine
This is Rietveld 408576698