Completely remove ResponseContext.io
This commit is contained in:
parent
697a1a788f
commit
90409711b4
3 changed files with 120 additions and 153 deletions
|
@ -3,7 +3,7 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/core/response_context.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/core/response_context.dart" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||
<ignored path="$PROJECT_DIR$/temp/" />
|
||||
|
@ -26,69 +26,18 @@
|
|||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="server.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/server.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="108">
|
||||
<caret line="8" column="62" selection-start-line="8" selection-start-column="62" selection-end-line="8" selection-end-column="62" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="419">
|
||||
<caret line="329" column="33" selection-start-line="328" selection-end-line="329" selection-end-column="33" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="response_context.dart" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="response_context.dart" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="48">
|
||||
<caret line="3" column="21" selection-start-line="3" selection-start-column="21" selection-end-line="3" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="routable.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/routable.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="928">
|
||||
<caret line="58" column="58" lean-forward="true" selection-start-line="58" selection-start-column="58" selection-end-line="58" selection-end-column="58" />
|
||||
<state relative-caret-position="-1261">
|
||||
<caret line="306" column="38" selection-start-line="306" selection-start-column="38" selection-end-line="306" selection-end-column="38" />
|
||||
<folding>
|
||||
<element signature="e#40#60#0" expanded="true" />
|
||||
<element signature="e#48#68#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="controller_test.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/controller_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="608">
|
||||
<caret line="48" column="18" selection-start-line="48" selection-start-column="18" selection-end-line="48" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="304">
|
||||
<caret line="19" column="13" selection-start-line="19" selection-start-column="13" selection-end-line="19" selection-end-column="13" />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="service.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
|
@ -104,8 +53,8 @@
|
|||
<file leaf-file-name="request_context.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/request_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="200">
|
||||
<caret line="70" column="16" lean-forward="true" selection-start-line="70" selection-start-column="16" selection-end-line="70" selection-end-column="16" />
|
||||
<state relative-caret-position="406">
|
||||
<caret line="158" column="23" lean-forward="true" selection-start-line="158" selection-start-column="23" selection-end-line="158" selection-end-column="23" />
|
||||
<folding>
|
||||
<element signature="e#47#67#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -113,6 +62,18 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="http_request_context.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/http_request_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="160">
|
||||
<caret line="10" column="25" lean-forward="true" selection-start-line="10" selection-start-column="25" selection-end-line="10" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="hooked_service.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/hooked_service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
|
@ -143,8 +104,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>Map<String,</find>
|
||||
<find>as</find>
|
||||
<find>redirectTo</find>
|
||||
<find>finalizers.t</find>
|
||||
<find>`Iterable`</find>
|
||||
|
@ -173,9 +132,10 @@
|
|||
<find>package:dart:io</find>
|
||||
<find>deprecated</find>
|
||||
<find>parse</find>
|
||||
<find>io.</find>
|
||||
<find>io</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>appa</replace>
|
||||
<replace>isClosed</replace>
|
||||
<replace>useStream</replace>
|
||||
<replace>streaming</replace>
|
||||
|
@ -205,6 +165,7 @@
|
|||
<replace>dart:convert</replace>
|
||||
<replace>dart:io</replace>
|
||||
<replace>json.decode</replace>
|
||||
<replace>rawRequest.</replace>
|
||||
</replaceStrings>
|
||||
<dirStrings>
|
||||
<dir>C:\Users\thosa\Source\Angel\framework\lib</dir>
|
||||
|
@ -228,7 +189,6 @@
|
|||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/lib/src/http/http_response_context.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/stats/metric_server.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/util.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/controller.dart" />
|
||||
|
@ -271,14 +231,15 @@
|
|||
<option value="$PROJECT_DIR$/lib/src/core/core.dart" />
|
||||
<option value="$PROJECT_DIR$/test/controller_test.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/routable.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/response_context.dart" />
|
||||
<option value="$PROJECT_DIR$/test/primitives_test.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/server.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/hooked_service.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/service.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/request_context.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/http_request_context.dart" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/response_context.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -697,21 +658,7 @@
|
|||
<workItem from="1533353660185" duration="262000" />
|
||||
<workItem from="1534009494986" duration="594000" />
|
||||
<workItem from="1534546784803" duration="353000" />
|
||||
<workItem from="1534547885788" duration="6986000" />
|
||||
</task>
|
||||
<task id="LOCAL-00083" summary="1.1.3">
|
||||
<created>1526440683707</created>
|
||||
<option name="number" value="00083" />
|
||||
<option name="presentableId" value="LOCAL-00083" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1526440683707</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00084" summary="Test against Dart 1.x">
|
||||
<created>1528441794043</created>
|
||||
<option name="number" value="00084" />
|
||||
<option name="presentableId" value="LOCAL-00084" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1528441794044</updated>
|
||||
<workItem from="1534547885788" duration="7562000" />
|
||||
</task>
|
||||
<task id="LOCAL-00085" summary="1.1.4+1">
|
||||
<created>1528442409476</created>
|
||||
|
@ -1042,7 +989,21 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1534735654118</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="132" />
|
||||
<task id="LOCAL-00132" summary="Make RequestContext generic">
|
||||
<created>1534735707304</created>
|
||||
<option name="number" value="00132" />
|
||||
<option name="presentableId" value="LOCAL-00132" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1534735707304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00133" summary="Completely remove RequestContext.io">
|
||||
<created>1534735919739</created>
|
||||
<option name="number" value="00133" />
|
||||
<option name="presentableId" value="LOCAL-00133" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1534735919739</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="134" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TestHistory">
|
||||
|
@ -1078,7 +1039,7 @@
|
|||
</history-entry>
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="169285000" />
|
||||
<option name="totallyTimeSpent" value="169861000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
|
@ -1141,7 +1102,6 @@
|
|||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<MESSAGE value="Bump version -> 1.1.5" />
|
||||
<MESSAGE value="Patched another cast bug" />
|
||||
<MESSAGE value="Removed random_string dependency" />
|
||||
<MESSAGE value="Switch to MediaType" />
|
||||
|
@ -1166,7 +1126,8 @@
|
|||
<MESSAGE value="Add more to parseId" />
|
||||
<MESSAGE value="Make parseId static + docs" />
|
||||
<MESSAGE value="Make RequestContext generic" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Make RequestContext generic" />
|
||||
<MESSAGE value="Completely remove RequestContext.io" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Completely remove RequestContext.io" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
@ -1174,13 +1135,6 @@
|
|||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.6.0/lib/src/path_set.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="470">
|
||||
<caret line="77" column="33" selection-start-line="77" selection-start-column="33" selection-end-line="77" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3/lib/src/core_matchers.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="86">
|
||||
|
@ -1462,13 +1416,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/controller_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="608">
|
||||
<caret line="48" column="18" selection-start-line="48" selection-start-column="18" selection-end-line="48" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/angel_route-2.0.7/lib/src/router.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="88">
|
||||
|
@ -1476,30 +1423,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="48">
|
||||
<caret line="3" column="21" selection-start-line="3" selection-start-column="21" selection-end-line="3" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="419">
|
||||
<caret line="329" column="33" selection-start-line="328" selection-end-line="329" selection-end-column="33" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/server.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="108">
|
||||
<caret line="8" column="62" selection-start-line="8" selection-start-column="62" selection-end-line="8" selection-end-column="62" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/safe_stream_controller.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-1402" />
|
||||
|
@ -1528,16 +1451,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/routable.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="928">
|
||||
<caret line="58" column="58" lean-forward="true" selection-start-line="58" selection-start-column="58" selection-end-line="58" selection-end-column="58" />
|
||||
<folding>
|
||||
<element signature="e#40#60#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-2042">
|
||||
|
@ -1548,12 +1461,29 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/request_context.dart">
|
||||
<entry file="file://$PROJECT_DIR$/test/controller_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="200">
|
||||
<caret line="70" column="16" lean-forward="true" selection-start-line="70" selection-start-column="16" selection-end-line="70" selection-end-column="16" />
|
||||
<state relative-caret-position="608">
|
||||
<caret line="48" column="18" selection-start-line="48" selection-start-column="18" selection-end-line="48" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/routable.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="191">
|
||||
<caret line="69" column="5" lean-forward="true" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="e#47#67#0" expanded="true" />
|
||||
<element signature="e#40#60#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/http_request_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="160">
|
||||
<caret line="10" column="25" lean-forward="true" selection-start-line="10" selection-start-column="25" selection-end-line="10" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -1561,13 +1491,53 @@
|
|||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="304">
|
||||
<caret line="19" column="13" selection-start-line="19" selection-start-column="13" selection-end-line="19" selection-end-column="13" />
|
||||
<first_editor relative-caret-position="336">
|
||||
<caret line="21" column="5" selection-start-line="21" selection-start-column="5" selection-end-line="21" selection-end-column="5" />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/request_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="406">
|
||||
<caret line="158" column="23" lean-forward="true" selection-start-line="158" selection-start-column="23" selection-end-line="158" selection-end-column="23" />
|
||||
<folding>
|
||||
<element signature="e#47#67#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/server.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="220">
|
||||
<caret line="137" column="16" selection-start-line="137" selection-start-column="16" selection-end-line="137" selection-end-column="16" />
|
||||
<folding>
|
||||
<element signature="e#38#58#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="435">
|
||||
<caret line="330" column="40" selection-start-line="330" selection-start-column="40" selection-end-line="330" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-1261">
|
||||
<caret line="306" column="38" selection-start-line="306" selection-start-column="38" selection-end-line="306" selection-end-column="38" />
|
||||
<folding>
|
||||
<element signature="e#48#68#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
|
|
@ -3,7 +3,7 @@ library angel_framework.http.response_context;
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:convert' as c show json;
|
||||
import 'dart:io' show BytesBuilder, Cookie, HttpResponse;
|
||||
import 'dart:io' show BytesBuilder, Cookie;
|
||||
|
||||
import 'package:angel_route/angel_route.dart';
|
||||
import 'package:file/file.dart';
|
||||
|
@ -18,7 +18,7 @@ import 'server.dart' show Angel;
|
|||
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
|
||||
|
||||
/// A convenience wrapper around an outgoing HTTP request.
|
||||
abstract class ResponseContext implements StreamSink<List<int>>, StringSink {
|
||||
abstract class ResponseContext<RawResponse> implements StreamSink<List<int>>, StringSink {
|
||||
final Map properties = {};
|
||||
final BytesBuilder _buffer = new _LockableBytesBuilder();
|
||||
final Map<String, String> _headers = {'server': 'angel'};
|
||||
|
@ -93,8 +93,8 @@ abstract class ResponseContext implements StreamSink<List<int>>, StringSink {
|
|||
/// A set of UTF-8 encoded bytes that will be written to the response.
|
||||
BytesBuilder get buffer => _buffer;
|
||||
|
||||
/// The underlying [HttpResponse] under this instance.
|
||||
HttpResponse get io;
|
||||
/// The underlying [RawResponse] under this instance.
|
||||
RawResponse get rawResponse;
|
||||
|
||||
/// Gets or sets the content type to send back to a client.
|
||||
MediaType contentType = new MediaType('text', 'plain');
|
||||
|
@ -305,11 +305,8 @@ abstract class ResponseContext implements StreamSink<List<int>>, StringSink {
|
|||
}
|
||||
|
||||
/// Streams a file to this response.
|
||||
///
|
||||
/// You can optionally transform the file stream with a [codec].
|
||||
Future streamFile(File file) {
|
||||
if (!isOpen) throw closed();
|
||||
|
||||
headers['content-type'] = lookupMimeType(file.path);
|
||||
return file.openRead().pipe(this);
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ import 'dart:io';
|
|||
import '../core/core.dart';
|
||||
import 'http_request_context.dart';
|
||||
|
||||
class HttpResponseContextImpl extends ResponseContext {
|
||||
class HttpResponseContextImpl extends ResponseContext<HttpResponse> {
|
||||
/// The underlying [HttpResponse] under this instance.
|
||||
@override
|
||||
final HttpResponse io;
|
||||
final HttpResponse rawResponse;
|
||||
Angel app;
|
||||
|
||||
final HttpRequestContextImpl _correspondingRequest;
|
||||
bool _isClosed = false, _useStream = false;
|
||||
|
||||
HttpResponseContextImpl(this.io, this.app, [this._correspondingRequest]);
|
||||
HttpResponseContextImpl(this.rawResponse, this.app, [this._correspondingRequest]);
|
||||
|
||||
@override
|
||||
RequestContext get correspondingRequest {
|
||||
|
@ -32,7 +32,7 @@ class HttpResponseContextImpl extends ResponseContext {
|
|||
|
||||
@override
|
||||
void addError(Object error, [StackTrace stackTrace]) {
|
||||
io.addError(error, stackTrace);
|
||||
rawResponse.addError(error, stackTrace);
|
||||
super.addError(error, stackTrace);
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,10 @@ class HttpResponseContextImpl extends ResponseContext {
|
|||
if (!_useStream) {
|
||||
// If this is the first stream added to this response,
|
||||
// then add headers, status code, etc.
|
||||
io
|
||||
rawResponse
|
||||
..statusCode = statusCode
|
||||
..cookies.addAll(cookies);
|
||||
headers.forEach(io.headers.set);
|
||||
headers.forEach(rawResponse.headers.set);
|
||||
willCloseItself = _useStream = _isClosed = true;
|
||||
releaseCorrespondingRequest();
|
||||
return true;
|
||||
|
@ -92,7 +92,7 @@ class HttpResponseContextImpl extends ResponseContext {
|
|||
|
||||
if (encoder != null) {
|
||||
if (firstStream) {
|
||||
io.headers.set('content-encoding', key);
|
||||
rawResponse.headers.set('content-encoding', key);
|
||||
}
|
||||
|
||||
output = encoders[key].bind(output);
|
||||
|
@ -102,7 +102,7 @@ class HttpResponseContextImpl extends ResponseContext {
|
|||
}
|
||||
}
|
||||
|
||||
return io.addStream(output);
|
||||
return rawResponse.addStream(output);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -110,7 +110,7 @@ class HttpResponseContextImpl extends ResponseContext {
|
|||
if (_isClosed && !_useStream)
|
||||
throw ResponseContext.closed();
|
||||
else if (_useStream)
|
||||
io.add(data);
|
||||
rawResponse.add(data);
|
||||
else
|
||||
buffer.add(data);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class HttpResponseContextImpl extends ResponseContext {
|
|||
Future close() {
|
||||
if (_useStream) {
|
||||
try {
|
||||
io.close();
|
||||
rawResponse.close();
|
||||
} catch (_) {
|
||||
// This only seems to occur on `MockHttpRequest`, but
|
||||
// this try/catch prevents a crash.
|
||||
|
|
Loading…
Reference in a new issue