-
Notifications
You must be signed in to change notification settings - Fork 382
Add support for request timeout #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
847ba46
e135dca
202af71
55d4cec
a8c31e5
c742e59
b94a86a
0fe2253
4f3dd71
329f6f4
bea9f64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
import 'dart:collection'; | ||
|
||
import 'package:meta/meta.dart'; | ||
|
@@ -117,11 +118,18 @@ abstract class BaseRequest { | |
/// the request is complete. If you're planning on making multiple requests to | ||
/// the same server, you should use a single [Client] for all of those | ||
/// requests. | ||
Future<StreamedResponse> send() async { | ||
/// | ||
/// If [contentTimeout] is not null the request will be aborted if it takes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd usually say "If [contentTimeout] is provided, the ...." |
||
/// longer than the given duration to receive the entire response. If the | ||
/// timeout occurs before any reply is received from the server the returned | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comma after "server"? |
||
/// future will as an error with a [TimeoutException]. If the timout occurs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a "will complete as" here? I'd usually write "the returned future will complete with a [TimeoutException] error." |
||
/// after the reply has been started but before the entire body has been read | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comma before "but"? (And then probably also after "read"). Maybe "has been started" -> "has started". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Don't think so, the '... but ...' is a single description of a condition, whereas a comma would suggest the two parts being separate sentences. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read "but before the entire body has been read" as parenthetical. |
||
/// the response stream will emit a [TimeoutException] and close. | ||
Future<StreamedResponse> send({Duration? contentTimeout}) async { | ||
var client = Client(); | ||
|
||
try { | ||
var response = await client.send(this); | ||
var response = await client.send(this, contentTimeout: contentTimeout); | ||
var stream = onDone(response.stream, client.close); | ||
return StreamedResponse(ByteStream(stream), response.statusCode, | ||
contentLength: response.contentLength, | ||
|
Uh oh!
There was an error while loading. Please reload this page.