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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 125743002: Add HttpRequest::requestedUri. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_requested_uri_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index ca47bd85db6a35f0d697fe7100153740040539bd..09e03c87a99b43ab9c51c62d7bf2dde746e9516c 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -90,6 +90,8 @@ class _HttpRequest extends _HttpInboundMessage implements HttpRequest {
_HttpSession _session;
+ Uri _requestedUri;
+
_HttpRequest(_HttpResponse this.response,
_HttpIncoming _incoming,
_HttpServer this._httpServer,
@@ -127,6 +129,27 @@ class _HttpRequest extends _HttpInboundMessage implements HttpRequest {
Uri get uri => _incoming.uri;
+ Uri get requestedUri {
+ if (_requestedUri == null) {
+ var proto = headers['x-forwarded-proto'];
+ var scheme = proto != null ? proto.first :
+ _httpConnection._socket is SecureSocket ? "https" : "http";
+ var host = headers['x-forwarded-host'];
+ if (host != null) {
+ host = host.first;
+ } else {
+ host = headers['host'];
+ if (host != null) {
+ host = host.first;
+ } else {
+ host = "${_httpServer.address.host}:${_httpServer.port}";
+ }
+ }
+ _requestedUri = Uri.parse("$scheme://$host$uri");
+ }
+ return _requestedUri;
+ }
+
String get method => _incoming.method;
HttpSession get session {
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_requested_uri_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698