Skip to content

Commit 6d3d7c5

Browse files
donny-dontnex3
authored andcommitted
dartfmt (#131)
1 parent 5983d3f commit 6d3d7c5

10 files changed

+69
-85
lines changed

lib/browser_client.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class BrowserClient extends BaseClient {
5252

5353
reader.onLoad.first.then((_) {
5454
var body = reader.result as Uint8List;
55-
completer.complete(new Response(
56-
xhr.responseUrl,
57-
xhr.status,
55+
completer.complete(new Response(xhr.responseUrl, xhr.status,
5856
reasonPhrase: xhr.statusText,
5957
body: new Stream.fromIterable([body]),
6058
headers: xhr.responseHeaders));

lib/http.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export 'src/response.dart';
3030
///
3131
/// For more fine-grained control over the request, use [Request] instead.
3232
Future<Response> head(url, {Map<String, String> headers}) =>
33-
_withClient((client) => client.head(url, headers: headers));
33+
_withClient((client) => client.head(url, headers: headers));
3434

3535
/// Sends an HTTP GET request with the given headers to the given URL, which can
3636
/// be a [Uri] or a [String].
@@ -41,7 +41,7 @@ Future<Response> head(url, {Map<String, String> headers}) =>
4141
///
4242
/// For more fine-grained control over the request, use [Request] instead.
4343
Future<Response> get(url, {Map<String, String> headers}) =>
44-
_withClient((client) => client.get(url, headers: headers));
44+
_withClient((client) => client.get(url, headers: headers));
4545

4646
/// Sends an HTTP POST request with the given headers and body to the given URL,
4747
/// which can be a [Uri] or a [String].
@@ -62,10 +62,10 @@ Future<Response> get(url, {Map<String, String> headers}) =>
6262
///
6363
/// For more fine-grained control over the request, use [Request] or
6464
/// [StreamedRequest] instead.
65-
Future<Response> post(url, body, {Map<String, String> headers,
66-
Encoding encoding}) =>
67-
_withClient((client) => client.post(url, body,
68-
headers: headers, encoding: encoding));
65+
Future<Response> post(url, body,
66+
{Map<String, String> headers, Encoding encoding}) =>
67+
_withClient((client) =>
68+
client.post(url, body, headers: headers, encoding: encoding));
6969

7070
/// Sends an HTTP PUT request with the given headers and body to the given URL,
7171
/// which can be a [Uri] or a [String].
@@ -86,10 +86,10 @@ Future<Response> post(url, body, {Map<String, String> headers,
8686
///
8787
/// For more fine-grained control over the request, use [Request] or
8888
/// [StreamedRequest] instead.
89-
Future<Response> put(url, body, {Map<String, String> headers,
90-
Encoding encoding}) =>
91-
_withClient((client) => client.put(url, body,
92-
headers: headers, encoding: encoding));
89+
Future<Response> put(url, body,
90+
{Map<String, String> headers, Encoding encoding}) =>
91+
_withClient((client) =>
92+
client.put(url, body, headers: headers, encoding: encoding));
9393

9494
/// Sends an HTTP PATCH request with the given headers and body to the given
9595
/// URL, which can be a [Uri] or a [String].
@@ -110,10 +110,10 @@ Future<Response> put(url, body, {Map<String, String> headers,
110110
///
111111
/// For more fine-grained control over the request, use [Request] or
112112
/// [StreamedRequest] instead.
113-
Future<Response> patch(url, body, {Map<String, String> headers,
114-
Encoding encoding}) =>
115-
_withClient((client) => client.patch(url, body,
116-
headers: headers, encoding: encoding));
113+
Future<Response> patch(url, body,
114+
{Map<String, String> headers, Encoding encoding}) =>
115+
_withClient((client) =>
116+
client.patch(url, body, headers: headers, encoding: encoding));
117117

118118
/// Sends an HTTP DELETE request with the given headers to the given URL, which
119119
/// can be a [Uri] or a [String].
@@ -124,7 +124,7 @@ Future<Response> patch(url, body, {Map<String, String> headers,
124124
///
125125
/// For more fine-grained control over the request, use [Request] instead.
126126
Future<Response> delete(url, {Map<String, String> headers}) =>
127-
_withClient((client) => client.delete(url, headers: headers));
127+
_withClient((client) => client.delete(url, headers: headers));
128128

129129
/// Sends an HTTP GET request with the given headers to the given URL, which can
130130
/// be a [Uri] or a [String], and returns a Future that completes to the body of
@@ -140,7 +140,7 @@ Future<Response> delete(url, {Map<String, String> headers}) =>
140140
/// For more fine-grained control over the request and response, use [Request]
141141
/// instead.
142142
Future<String> read(url, {Map<String, String> headers}) =>
143-
_withClient((client) => client.read(url, headers: headers));
143+
_withClient((client) => client.read(url, headers: headers));
144144

145145
/// Sends an HTTP GET request with the given headers to the given URL, which can
146146
/// be a [Uri] or a [String], and returns a Future that completes to the body of
@@ -156,7 +156,7 @@ Future<String> read(url, {Map<String, String> headers}) =>
156156
/// For more fine-grained control over the request and response, use [Request]
157157
/// instead.
158158
Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
159-
_withClient((client) => client.readBytes(url, headers: headers));
159+
_withClient((client) => client.readBytes(url, headers: headers));
160160

161161
Future<T> _withClient<T>(Future<T> fn(Client client)) async {
162162
var client = new Client();

lib/src/base_client.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ abstract class BaseClient implements Client {
2222
///
2323
/// For more fine-grained control over the request, use [send] instead.
2424
Future<Response> head(url, {Map<String, String> headers}) =>
25-
send(new Request.head(url, headers: headers));
25+
send(new Request.head(url, headers: headers));
2626

2727
/// Sends an HTTP GET request with the given headers to the given URL, which
2828
/// can be a [Uri] or a [String].
2929
///
3030
/// For more fine-grained control over the request, use [send] instead.
3131
Future<Response> get(url, {Map<String, String> headers}) =>
32-
send(new Request.get(url, headers: headers));
32+
send(new Request.get(url, headers: headers));
3333

3434
/// Sends an HTTP POST request with the given headers and body to the given
3535
/// URL, which can be a [Uri] or a [String].
@@ -49,10 +49,9 @@ abstract class BaseClient implements Client {
4949
/// [encoding] defaults to UTF-8.
5050
///
5151
/// For more fine-grained control over the request, use [send] instead.
52-
Future<Response> post(url, body, {Map<String, String> headers,
53-
Encoding encoding}) =>
54-
send(new Request.post(url, body, headers: headers,
55-
encoding: encoding));
52+
Future<Response> post(url, body,
53+
{Map<String, String> headers, Encoding encoding}) =>
54+
send(new Request.post(url, body, headers: headers, encoding: encoding));
5655

5756
/// Sends an HTTP PUT request with the given headers and body to the given
5857
/// URL, which can be a [Uri] or a [String].
@@ -72,10 +71,9 @@ abstract class BaseClient implements Client {
7271
/// [encoding] defaults to UTF-8.
7372
///
7473
/// For more fine-grained control over the request, use [send] instead.
75-
Future<Response> put(url, body, {Map<String, String> headers,
76-
Encoding encoding}) =>
77-
send(new Request.put(url, body, headers: headers,
78-
encoding: encoding));
74+
Future<Response> put(url, body,
75+
{Map<String, String> headers, Encoding encoding}) =>
76+
send(new Request.put(url, body, headers: headers, encoding: encoding));
7977

8078
/// Sends an HTTP PATCH request with the given headers and body to the given
8179
/// URL, which can be a [Uri] or a [String].
@@ -95,10 +93,9 @@ abstract class BaseClient implements Client {
9593
/// [encoding] defaults to UTF-8.
9694
///
9795
/// For more fine-grained control over the request, use [send] instead.
98-
Future<Response> patch(url, body, {Map<String, String> headers,
99-
Encoding encoding}) =>
100-
send(new Request.patch(url, body, headers: headers,
101-
encoding: encoding));
96+
Future<Response> patch(url, body,
97+
{Map<String, String> headers, Encoding encoding}) =>
98+
send(new Request.patch(url, body, headers: headers, encoding: encoding));
10299

103100
/// Sends an HTTP DELETE request with the given headers to the given URL,
104101
/// which can be a [Uri] or a [String].

lib/src/client.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ abstract class Client {
3636
/// [Future<Response>]. It will be called when [Client.send] is invoked.
3737
///
3838
/// When [Client.close] is called the [onClose] function will be called.
39-
factory Client.handler(Handler handler, {void onClose()})
40-
=> new HandlerClient(handler, onClose ?? () {});
39+
factory Client.handler(Handler handler, {void onClose()}) =>
40+
new HandlerClient(handler, onClose ?? () {});
4141

4242
/// Sends an HTTP HEAD request with the given headers to the given URL, which
4343
/// can be a [Uri] or a [String].
@@ -69,8 +69,8 @@ abstract class Client {
6969
/// [encoding] defaults to [UTF8].
7070
///
7171
/// For more fine-grained control over the request, use [send] instead.
72-
Future<Response> post(url, body, {Map<String, String> headers,
73-
Encoding encoding});
72+
Future<Response> post(url, body,
73+
{Map<String, String> headers, Encoding encoding});
7474

7575
/// Sends an HTTP PUT request with the given headers and body to the given
7676
/// URL, which can be a [Uri] or a [String].
@@ -90,8 +90,8 @@ abstract class Client {
9090
/// [encoding] defaults to [UTF8].
9191
///
9292
/// For more fine-grained control over the request, use [send] instead.
93-
Future<Response> put(url, body, {Map<String, String> headers,
94-
Encoding encoding});
93+
Future<Response> put(url, body,
94+
{Map<String, String> headers, Encoding encoding});
9595

9696
/// Sends an HTTP PATCH request with the given headers and body to the given
9797
/// URL, which can be a [Uri] or a [String].
@@ -111,8 +111,8 @@ abstract class Client {
111111
/// [encoding] defaults to [UTF8].
112112
///
113113
/// For more fine-grained control over the request, use [send] instead.
114-
Future<Response> patch(url, body, {Map<String, String> headers,
115-
Encoding encoding});
114+
Future<Response> patch(url, body,
115+
{Map<String, String> headers, Encoding encoding});
116116

117117
/// Sends an HTTP DELETE request with the given headers to the given URL,
118118
/// which can be a [Uri] or a [String].

lib/src/handler_client.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class HandlerClient extends BaseClient {
1818
final void Function() _close;
1919

2020
/// Creates a new client using the [_handler] and [onClose] functions.
21-
HandlerClient(this._handler, void onClose())
22-
: _close = onClose;
21+
HandlerClient(this._handler, void onClose()) : _close = onClose;
2322

2423
/// Sends an HTTP request and asynchronously returns the response.
2524
Future<Response> send(Request request) => _handler(request);

lib/src/io_client.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class IOClient extends BaseClient {
2929
var context = request.context;
3030

3131
ioRequest
32-
..followRedirects = context['io.followRedirects'] ?? true
33-
..maxRedirects = context['io.maxRedirects'] ?? 5
34-
..persistentConnection = context['io.persistentConnection'] ?? true;
32+
..followRedirects = context['io.followRedirects'] ?? true
33+
..maxRedirects = context['io.maxRedirects'] ?? 5
34+
..persistentConnection = context['io.persistentConnection'] ?? true;
3535
request.headers.forEach((name, value) {
3636
ioRequest.headers.set(name, value);
3737
});
@@ -44,9 +44,7 @@ class IOClient extends BaseClient {
4444
headers[key] = values.join(',');
4545
});
4646

47-
return new Response(
48-
_responseUrl(request, response),
49-
response.statusCode,
47+
return new Response(_responseUrl(request, response), response.statusCode,
5048
reasonPhrase: response.reasonPhrase,
5149
body: DelegatingStream.typed<List<int>>(response).handleError(
5250
(error) => throw new ClientException(error.message, error.uri),

lib/src/middleware.dart

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,25 @@ typedef Client Middleware(Client inner);
4040
/// If provided, [errorHandler] receives errors thrown by the inner handler. It
4141
/// does not receive errors thrown by [requestHandler] or [responseHandler].
4242
/// It can either return a new response or throw an error.
43-
Middleware createMiddleware({
44-
Future<Request> requestHandler(Request request),
45-
Future<Response> responseHandler(Response response),
46-
void onClose(),
47-
void errorHandler(error, [StackTrace stackTrace])
48-
}) {
43+
Middleware createMiddleware(
44+
{Future<Request> requestHandler(Request request),
45+
Future<Response> responseHandler(Response response),
46+
void onClose(),
47+
void errorHandler(error, [StackTrace stackTrace])}) {
4948
requestHandler ??= (request) async => request;
5049
responseHandler ??= (response) async => response;
5150

5251
return (inner) {
5352
return new HandlerClient(
54-
(request) =>
55-
requestHandler(request)
56-
.then((req) => inner.send(req))
57-
.then((res) => responseHandler(res), onError: errorHandler),
58-
onClose == null
59-
? inner.close
60-
: () {
61-
onClose();
62-
inner.close();
63-
},
53+
(request) => requestHandler(request)
54+
.then((req) => inner.send(req))
55+
.then((res) => responseHandler(res), onError: errorHandler),
56+
onClose == null
57+
? inner.close
58+
: () {
59+
onClose();
60+
inner.close();
61+
},
6462
);
6563
};
6664
}

lib/src/response.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ class Response extends Message {
4242
Encoding encoding,
4343
Map<String, String> headers,
4444
Map<String, Object> context})
45-
: this._(getUrl(finalUrl), statusCode, reasonPhrase ?? '',
46-
body, encoding, headers, context);
45+
: this._(getUrl(finalUrl), statusCode, reasonPhrase ?? '', body, encoding,
46+
headers, context);
4747

48-
Response._(this.finalUrl, this.statusCode, this.reasonPhrase,
48+
Response._(
49+
this.finalUrl,
50+
this.statusCode,
51+
this.reasonPhrase,
4952
body,
5053
Encoding encoding,
5154
Map<String, String> headers,
@@ -68,20 +71,12 @@ class Response extends Message {
6871
/// [body] is the request body. It may be either a [String], a [List<int>], a
6972
/// [Stream<List<int>>], or `null` to indicate no body.
7073
Response change(
71-
{Map<String, String> headers,
72-
Map<String, Object> context,
73-
body}) {
74+
{Map<String, String> headers, Map<String, Object> context, body}) {
7475
var updatedHeaders = updateMap(this.headers, headers);
7576
var updatedContext = updateMap(this.context, context);
7677

77-
return new Response._(
78-
this.finalUrl,
79-
this.statusCode,
80-
this.reasonPhrase,
81-
body ?? getBody(this),
82-
this.encoding,
83-
updatedHeaders,
84-
updatedContext);
78+
return new Response._(this.finalUrl, this.statusCode, this.reasonPhrase,
79+
body ?? getBody(this), this.encoding, updatedHeaders, updatedContext);
8580
}
8681

8782
/// The date and time after which the response's data should be considered
@@ -95,6 +90,7 @@ class Response extends Message {
9590
_expiresCache = parseHttpDate(headers['expires']);
9691
return _expiresCache;
9792
}
93+
9894
DateTime _expiresCache;
9995

10096
/// The date and time the source of the response's data was last modified.
@@ -107,5 +103,6 @@ class Response extends Message {
107103
_lastModifiedCache = parseHttpDate(headers['last-modified']);
108104
return _lastModifiedCache;
109105
}
106+
110107
DateTime _lastModifiedCache;
111108
}

test/hybrid/server.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ hybridMain(StreamChannel channel) async {
113113
requestBody = null;
114114
} else if (request.headers.contentType != null &&
115115
request.headers.contentType.charset != null) {
116-
var encoding =
117-
encodingForCharset(request.headers.contentType.charset);
116+
var encoding = encodingForCharset(request.headers.contentType.charset);
118117
requestBody = encoding.decode(requestBodyBytes);
119118
} else {
120119
requestBody = requestBodyBytes;

test/multipart_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ void main() {
180180
// "Ã¥" encoded as ISO-8859-1 and then read as UTF-8 results in "å".
181181
var files = [
182182
new http.MultipartFile('file', 'non-ascii: "Ã¥"',
183-
encoding: LATIN1,
184-
contentType:
185-
new MediaType('text', 'plain'))
183+
encoding: LATIN1, contentType: new MediaType('text', 'plain'))
186184
];
187185
var request = new http.Request.multipart(dummyUrl, files: files);
188186

0 commit comments

Comments
 (0)