@@ -134,7 +134,7 @@ class Request extends Message {
134
134
body,
135
135
Encoding encoding,
136
136
Map <String , Object > context,
137
- void onHijack (void hijack (StreamChannel <List <int >> channel)) })
137
+ void Function (void Function (StreamChannel <List <int >>)) onHijack })
138
138
: this ._(method, requestedUri,
139
139
protocolVersion: protocolVersion,
140
140
headers: headers,
@@ -160,12 +160,11 @@ class Request extends Message {
160
160
Encoding encoding,
161
161
Map <String , Object > context,
162
162
_OnHijack onHijack})
163
- : this .requestedUri = requestedUri,
164
- this .protocolVersion =
165
- protocolVersion == null ? '1.1' : protocolVersion,
166
- this .url = _computeUrl (requestedUri, handlerPath, url),
167
- this .handlerPath = _computeHandlerPath (requestedUri, handlerPath, url),
168
- this ._onHijack = onHijack,
163
+ : requestedUri = requestedUri,
164
+ protocolVersion = protocolVersion ?? '1.1' ,
165
+ url = _computeUrl (requestedUri, handlerPath, url),
166
+ handlerPath = _computeHandlerPath (requestedUri, handlerPath, url),
167
+ _onHijack = onHijack,
169
168
super (body, encoding: encoding, headers: headers, context: context) {
170
169
if (method.isEmpty) {
171
170
throw ArgumentError .value (method, 'method' , 'cannot be empty.' );
@@ -214,6 +213,7 @@ class Request extends Message {
214
213
/// request = request.change(path: "dir");
215
214
/// print(request.handlerPath); // => /static/dir/
216
215
/// print(request.url); // => file.html
216
+ @override
217
217
Request change (
218
218
{Map <String , String > headers,
219
219
Map <String , Object > context,
@@ -222,13 +222,13 @@ class Request extends Message {
222
222
headers = updateMap (this .headers, headers);
223
223
context = updateMap (this .context, context);
224
224
225
- if ( body == null ) body = getBody (this );
225
+ body ?? = getBody (this );
226
226
227
227
var handlerPath = this .handlerPath;
228
228
if (path != null ) handlerPath += path;
229
229
230
- return Request ._(this . method, this . requestedUri,
231
- protocolVersion: this . protocolVersion,
230
+ return Request ._(method, requestedUri,
231
+ protocolVersion: protocolVersion,
232
232
headers: headers,
233
233
handlerPath: handlerPath,
234
234
body: body,
@@ -247,7 +247,7 @@ class Request extends Message {
247
247
/// hijacking, such as the `dart:io` adapter. In addition, a given request may
248
248
/// only be hijacked once. [canHijack] can be used to detect whether this
249
249
/// request can be hijacked.
250
- void hijack (void callback (StreamChannel <List <int >> channel) ) {
250
+ void hijack (void Function (StreamChannel <List <int >>) callback ) {
251
251
if (_onHijack == null ) {
252
252
throw StateError ("This request can't be hijacked." );
253
253
}
@@ -272,8 +272,8 @@ class _OnHijack {
272
272
/// Calls [this] .
273
273
///
274
274
/// Throws a [StateError] if [this] has already been called.
275
- void run (void callback (StreamChannel <List <int >> channel) ) {
276
- if (called) throw StateError (" This request has already been hijacked." );
275
+ void run (void Function (StreamChannel <List <int >>) callback ) {
276
+ if (called) throw StateError (' This request has already been hijacked.' );
277
277
called = true ;
278
278
newFuture (() => _callback (callback));
279
279
}
@@ -286,8 +286,8 @@ class _OnHijack {
286
286
Uri _computeUrl (Uri requestedUri, String handlerPath, Uri url) {
287
287
if (handlerPath != null &&
288
288
handlerPath != requestedUri.path &&
289
- ! handlerPath.endsWith ("/" )) {
290
- handlerPath += "/" ;
289
+ ! handlerPath.endsWith ('/' )) {
290
+ handlerPath += '/' ;
291
291
}
292
292
293
293
if (url != null ) {
@@ -336,8 +336,8 @@ Uri _computeUrl(Uri requestedUri, String handlerPath, Uri url) {
336
336
String _computeHandlerPath (Uri requestedUri, String handlerPath, Uri url) {
337
337
if (handlerPath != null &&
338
338
handlerPath != requestedUri.path &&
339
- ! handlerPath.endsWith ("/" )) {
340
- handlerPath += "/" ;
339
+ ! handlerPath.endsWith ('/' )) {
340
+ handlerPath += '/' ;
341
341
}
342
342
343
343
if (handlerPath != null ) {
0 commit comments