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

Unified Diff: pkg/shelf/lib/src/request.dart

Issue 616463004: pkg/shelf: include the original `onHijack` callback for Request.change (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cl nits Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/CHANGELOG.md ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/lib/src/request.dart
diff --git a/pkg/shelf/lib/src/request.dart b/pkg/shelf/lib/src/request.dart
index 26fe011ff8d6b96135599d11574577556d4bdf79..15d8b87a52982ddb5cd5a8180ffa4cd26d10b487 100644
--- a/pkg/shelf/lib/src/request.dart
+++ b/pkg/shelf/lib/src/request.dart
@@ -116,16 +116,31 @@ class Request extends Message {
///
/// See also [hijack].
// TODO(kevmoo) finish documenting the rest of the arguments.
- Request(this.method, Uri requestedUri, {String protocolVersion,
+ Request(String method, Uri requestedUri, {String protocolVersion,
+ Map<String, String> headers, Uri url, String scriptName,
+ Stream<List<int>> body, Map<String, Object> context,
+ OnHijackCallback onHijack})
+ : this._(method, requestedUri, protocolVersion: protocolVersion,
+ headers: headers, url: url, scriptName: scriptName,
+ body: body, context: context,
+ onHijack: onHijack == null ? null : new _OnHijack(onHijack));
+
+ /// This constructor has the same signature as [new Request] except that
+ /// accepts [onHijack] as [_OnHijack].
+ ///
+ /// Any [Request] created by calling [change] will pass [_onHijack] from the
+ /// source [Request] to ensure that [hijack] can only be called once, even
+ /// from a changed [Request].
+ Request._(this.method, Uri requestedUri, {String protocolVersion,
Map<String, String> headers, Uri url, String scriptName,
Stream<List<int>> body, Map<String, Object> context,
- OnHijackCallback onHijack})
+ _OnHijack onHijack})
: this.requestedUri = requestedUri,
this.protocolVersion = protocolVersion == null ?
'1.1' : protocolVersion,
this.url = _computeUrl(requestedUri, url, scriptName),
this.scriptName = _computeScriptName(requestedUri, url, scriptName),
- this._onHijack = onHijack == null ? null : new _OnHijack(onHijack),
+ this._onHijack = onHijack,
super(body == null ? new Stream.fromIterable([]) : body,
headers: headers, context: context) {
if (method.isEmpty) throw new ArgumentError('method cannot be empty.');
@@ -194,9 +209,10 @@ class Request extends Message {
if (url == null) url = this.url;
if (scriptName == null) scriptName = this.scriptName;
- return new Request(this.method, this.requestedUri,
+ return new Request._(this.method, this.requestedUri,
protocolVersion: this.protocolVersion, headers: headers, url: url,
- scriptName: scriptName, body: this.read(), context: context);
+ scriptName: scriptName, body: this.read(), context: context,
+ onHijack: _onHijack);
}
/// Takes control of the underlying request socket.
« no previous file with comments | « pkg/shelf/CHANGELOG.md ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698