Add HttpConnectionInfo to shelf_io Request context (#92)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2211082..62e48fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,13 +1,17 @@
 ## 0.7.1
 
-* Update minimum Dart SDK to 1.23.0.
+* The `shelf_io` server now adds a `shelf.io.connection_info` field to
+  `Request.context`, which provides access to the underlying
+  `HttpConnectionInfo` object.
 
 ## 0.7.0
 
 * Give a return type to the `Handler` typedef. This may cause static warnings
   where there previously were none, but all handlers should have already been
   returning a `Response` or `Future<Response>`.
+
 * Remove `HijackCallback` and `OnHijackCallback` typedefs.
+
 * **Breaking**: Change type of `onHijack` in the `Request` constructor to take
   an argument of `StreamChannel`.
 
diff --git a/lib/shelf_io.dart b/lib/shelf_io.dart
index d091c76..cf457be 100644
--- a/lib/shelf_io.dart
+++ b/lib/shelf_io.dart
@@ -14,6 +14,10 @@
 /// wire as they're received. See [`HttpResponse.bufferOutput`][bufferOutput]
 /// for more information.
 ///
+/// `Request`s passed to a `Handler` will contain the
+/// `"shelf.io.connection_info"` `Request.context` property, which holds the
+/// `HttpConnectionInfo` object from the underlying `HttpRequest`.
+///
 /// [bufferOutput]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:io.HttpResponse#id_bufferOutput
 import 'dart:async';
 import 'dart:io';
@@ -133,7 +137,8 @@
       protocolVersion: request.protocolVersion,
       headers: headers,
       body: request,
-      onHijack: onHijack);
+      onHijack: onHijack,
+      context: {'shelf.io.connection_info': request.connectionInfo});
 }
 
 Future _writeResponse(Response response, HttpResponse httpResponse) {
diff --git a/pubspec.yaml b/pubspec.yaml
index b3f220e..11ff97c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: shelf
-version: 0.7.1-dev
+version: 0.7.1
 author: Dart Team <misc@dartlang.org>
 description: Web Server Middleware for Dart
 homepage: https://github.com/dart-lang/shelf
diff --git a/test/shelf_io_test.dart b/test/shelf_io_test.dart
index 49585a8..414a3f3 100644
--- a/test/shelf_io_test.dart
+++ b/test/shelf_io_test.dart
@@ -455,6 +455,25 @@
     expect(stream.hasNext, completion(isFalse));
   });
 
+  test('includes the dart:io HttpConnectionInfo in request context', () async {
+    await _scheduleServer((request) {
+      expect(
+          request.context,
+          containsPair('shelf.io.connection_info',
+              new isInstanceOf<HttpConnectionInfo>()));
+
+      var connectionInfo =
+          request.context['shelf.io.connection_info'] as HttpConnectionInfo;
+      expect(connectionInfo.remoteAddress, equals(_server.address));
+      expect(connectionInfo.localPort, equals(_server.port));
+
+      return syncHandler(request);
+    });
+
+    var response = await _get();
+    expect(response.statusCode, HttpStatus.OK);
+  });
+
   group('ssl tests', () {
     var securityContext = new SecurityContext()
       ..setTrustedCertificatesBytes(certChainBytes)