Remove releaseCOrrespondingRequest

This commit is contained in:
Tobe O 2018-08-20 21:57:26 -04:00
parent 15e5cef691
commit 2b1a548cf9
7 changed files with 221 additions and 183 deletions

View file

@ -3,8 +3,12 @@
<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" />
<change beforePath="$PROJECT_DIR$/lib/src/core/server.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/core/server.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/http/angel_http.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/http/angel_http.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/http/http_response_context.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/http/http_response_context.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/routing_test.dart" beforeDir="false" afterPath="$PROJECT_DIR$/test/routing_test.dart" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
@ -27,35 +31,65 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
<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="588">
<caret line="58" column="75" selection-start-line="58" selection-start-column="75" selection-end-line="58" selection-end-column="75" />
</first_editor>
<second_editor />
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="301">
<caret line="24" column="16" selection-start-line="24" selection-start-column="16" selection-end-line="24" selection-end-column="16" />
<folding>
<element signature="e#0#46#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="response_context.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
<file leaf-file-name="routing_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="260">
<caret line="394" column="8" lean-forward="true" selection-start-line="394" selection-start-column="8" selection-end-line="394" selection-end-column="8" />
<state relative-caret-position="182">
<caret line="27" column="13" selection-start-line="27" selection-start-column="13" selection-end-line="27" selection-end-column="13" />
</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="252">
<caret line="286" column="39" selection-start-line="286" selection-start-column="39" selection-end-line="286" selection-end-column="39" />
<folding>
<element signature="e#48#68#0" expanded="true" />
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<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="-1483">
<caret line="153" column="15" selection-start-line="153" selection-start-column="15" selection-end-line="153" selection-end-column="15" />
<folding>
<element signature="e#38#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="json.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/json.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-282">
<caret column="20" selection-start-column="20" selection-end-column="20" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="http_response_context.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="13" column="43" selection-start-line="13" selection-start-column="43" selection-end-line="13" selection-end-column="43" />
<state relative-caret-position="129">
<caret line="56" column="19" lean-forward="true" selection-start-line="56" selection-start-column="19" selection-end-line="56" selection-end-column="19" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
@ -63,6 +97,30 @@
</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="283">
<caret line="62" column="49" selection-start-line="62" selection-start-column="49" selection-end-line="62" selection-end-column="49" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="response_context.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="258">
<caret line="119" column="9" selection-start-line="119" selection-start-column="9" selection-end-line="119" selection-end-column="9" />
<folding>
<element signature="e#48#68#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -75,12 +133,8 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>reflector</find>
<find>Angel(M</find>
<find>pool</find>
<find>super</find>
<find>close()</find>
<find>close(</find>
<find>DEFUNC</find>
<find>const</find>
<find>dart2_constant/convert.dart</find>
@ -105,9 +159,12 @@
<find>injecti</find>
<find>debug</find>
<find>handle(</find>
<find>lock</find>
<find>add(</find>
<find>close(</find>
<find>end()</find>
</findStrings>
<replaceStrings>
<replace>'server'</replace>
<replace>FutureOr</replace>
<replace>var body = await getBody(rs);</replace>
<replace />
@ -137,6 +194,7 @@
<replace>));</replace>
<replace>req</replace>
<replace>req.container</replace>
<replace>close()</replace>
</replaceStrings>
<dirStrings>
<dir>C:\Users\thosa\Source\Angel\framework\lib</dir>
@ -202,15 +260,15 @@
<option value="$PROJECT_DIR$/lib/src/core/routable.dart" />
<option value="$PROJECT_DIR$/lib/src/http/controller.dart" />
<option value="$PROJECT_DIR$/example/handle_error.dart" />
<option value="$PROJECT_DIR$/test/routing_test.dart" />
<option value="$PROJECT_DIR$/test/server_test.dart" />
<option value="$PROJECT_DIR$/example/json.dart" />
<option value="$PROJECT_DIR$/lib/src/core/response_context.dart" />
<option value="$PROJECT_DIR$/test/routing_test.dart" />
<option value="$PROJECT_DIR$/lib/src/core/server.dart" />
<option value="$PROJECT_DIR$/example/main.dart" />
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
<option value="$PROJECT_DIR$/example/json.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/lib/src/http/http_response_context.dart" />
<option value="$PROJECT_DIR$/lib/src/core/response_context.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
</list>
</option>
</component>
@ -247,6 +305,11 @@
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="example" type="cbb8eebc:String" user="example" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
@ -313,7 +376,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Dart Command Line App.performance::hello::raw">
<component name="RunManager" selected="Dart Command Line App.main.dart">
<configuration name="Can serialize function result as JSON in routing_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/test/routing_test.dart" />
<option name="scope" value="GROUP_OR_TEST_BY_NAME" />
@ -613,21 +676,7 @@
<workItem from="1534009494986" duration="594000" />
<workItem from="1534546784803" duration="353000" />
<workItem from="1534547885788" duration="9908000" />
<workItem from="1534793956753" duration="8159000" />
</task>
<task id="LOCAL-00106" summary="Bump version -&gt; 1.1.5">
<created>1531409300283</created>
<option name="number" value="00106" />
<option name="presentableId" value="LOCAL-00106" />
<option name="project" value="LOCAL" />
<updated>1531409300283</updated>
</task>
<task id="LOCAL-00107" summary="Patched another cast bug">
<created>1533353912000</created>
<option name="number" value="00107" />
<option name="presentableId" value="LOCAL-00107" />
<option name="project" value="LOCAL" />
<updated>1533353912001</updated>
<workItem from="1534793956753" duration="9486000" />
</task>
<task id="LOCAL-00108" summary="Removed random_string dependency">
<created>1534547008912</created>
@ -958,7 +1007,21 @@
<option name="project" value="LOCAL" />
<updated>1534814859355</updated>
</task>
<option name="localTasksCounter" value="155" />
<task id="LOCAL-00155" summary="Make LockableBytesBuilder public">
<created>1534815148128</created>
<option name="number" value="00155" />
<option name="presentableId" value="LOCAL-00155" />
<option name="project" value="LOCAL" />
<updated>1534815148128</updated>
</task>
<task id="LOCAL-00156" summary="Remove ResponseContext.dispose">
<created>1534815933898</created>
<option name="number" value="00156" />
<option name="presentableId" value="LOCAL-00156" />
<option name="project" value="LOCAL" />
<updated>1534815933898</updated>
</task>
<option name="localTasksCounter" value="157" />
<servers />
</component>
<component name="TestHistory">
@ -994,7 +1057,7 @@
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="180366000" />
<option name="totallyTimeSpent" value="181693000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -1030,7 +1093,7 @@
<window_info id="Image Layers" order="2" />
<window_info anchor="right" id="Capture Analysis" order="3" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32905984" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.4964476" weight="0.3973799" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.4964476" visible="true" weight="0.3973799" />
<window_info anchor="bottom" id="Terminal" order="7" weight="0.44978166" />
<window_info content_ui="combo" id="Project" order="0" weight="0.27846155" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32905984" />
@ -1057,8 +1120,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="Add more to parseId" />
<MESSAGE value="Make parseId static + docs" />
<MESSAGE value="Make RequestContext generic" />
<MESSAGE value="Completely remove RequestContext.io" />
<MESSAGE value="Completely remove ResponseContext.io" />
@ -1082,7 +1143,9 @@
<MESSAGE value="Add flags to Angel constructor" />
<MESSAGE value="Catch sync errors when using zone" />
<MESSAGE value="ResponseContext.isBuffered" />
<option name="LAST_COMMIT_MESSAGE" value="ResponseContext.isBuffered" />
<MESSAGE value="Make LockableBytesBuilder public" />
<MESSAGE value="Remove ResponseContext.dispose" />
<option name="LAST_COMMIT_MESSAGE" value="Remove ResponseContext.dispose" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -1245,16 +1308,6 @@
</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="257">
<caret line="160" column="31" lean-forward="true" selection-start-line="160" selection-start-column="31" selection-end-line="160" selection-end-column="31" />
<folding>
<element signature="e#47#67#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.3/lib/src/utils.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="181">
@ -1290,16 +1343,6 @@
</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="262">
<caret line="96" column="14" selection-start-line="96" selection-start-column="14" selection-end-line="96" selection-end-column="14" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/hooked_service.dart">
<provider selected="true" editor-type-id="text-editor">
<state>
@ -1320,16 +1363,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="42">
<caret line="22" column="10" lean-forward="true" selection-start-line="22" selection-start-column="10" selection-end-line="22" selection-end-column="10" />
<folding>
<element signature="e#0#46#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file:///usr/local/Cellar/dart/2.0.0/libexec/lib/async/zone.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="859">
@ -1337,13 +1370,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="182">
<caret line="195" column="18" lean-forward="true" selection-start-line="195" selection-start-column="18" selection-end-line="195" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/server_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="160">
@ -1351,16 +1377,6 @@
</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="129">
<caret line="254" column="26" selection-start-line="254" selection-start-column="26" selection-end-line="254" selection-end-column="26" />
<folding>
<element signature="e#38#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file:///usr/local/opt/dart/libexec/lib/async/future_impl.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="129">
@ -1382,16 +1398,6 @@
</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="302">
<caret line="32" column="2" selection-start-line="32" selection-start-column="2" selection-end-line="32" selection-end-column="2" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/handle_error.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
@ -1431,10 +1437,81 @@
</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="257">
<caret line="20" column="15" selection-start-line="20" selection-start-column="15" selection-end-line="20" selection-end-column="15" />
<folding>
<element signature="e#47#67#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="80">
<caret line="5" column="46" lean-forward="true" selection-start-line="5" selection-start-column="46" selection-end-line="5" selection-end-column="46" />
</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="258">
<caret line="119" column="9" selection-start-line="119" selection-start-column="9" selection-end-line="119" selection-end-column="9" />
<folding>
<element signature="e#48#68#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/json.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="294">
<caret line="37" lean-forward="true" selection-start-line="37" selection-end-line="37" />
<state relative-caret-position="-282">
<caret column="20" selection-start-column="20" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="182">
<caret line="27" column="13" selection-start-line="27" selection-start-column="13" selection-end-line="27" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="301">
<caret line="24" column="16" selection-start-line="24" selection-start-column="16" selection-end-line="24" selection-end-column="16" />
<folding>
<element signature="e#0#46#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="-1483">
<caret line="153" column="15" selection-start-line="153" selection-start-column="15" selection-end-line="153" selection-end-column="15" />
<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="252">
<caret line="286" column="39" selection-start-line="286" selection-start-column="39" selection-end-line="286" selection-end-column="39" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="129">
<caret line="56" column="19" lean-forward="true" selection-start-line="56" selection-start-column="19" selection-end-line="56" selection-end-column="19" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
@ -1444,33 +1521,13 @@
<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="588">
<caret line="58" column="75" selection-start-line="58" selection-start-column="75" selection-end-line="58" selection-end-column="75" />
<first_editor relative-caret-position="283">
<caret line="62" column="49" selection-start-line="62" selection-start-column="49" selection-end-line="62" selection-end-column="49" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="13" column="43" selection-start-line="13" selection-start-column="43" selection-end-line="13" selection-end-column="43" />
<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="260">
<caret line="394" column="8" lean-forward="true" selection-start-line="394" selection-start-column="8" selection-end-line="394" selection-end-column="8" />
<folding>
<element signature="e#48#68#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

View file

@ -60,3 +60,5 @@ as in many cases it is unnecessary and slows down response time.
* Made `LockableBytesBuilder` public.
* Removed the now-obsolete `ResponseContext.willCloseItself`.
* Removed `ResponseContext.dispose`.
* Removed the now-obsolete `ResponseContext.end`.
* Removed the now-obsolete `ResponseContext.releaseCorrespondingRequest`.

View file

@ -110,7 +110,7 @@ abstract class ResponseContext<RawResponse>
file.openRead().pipe(this);
} else {
buffer.add(file.readAsBytesSync());
end();
close();
}
}
@ -126,15 +126,6 @@ abstract class ResponseContext<RawResponse>
return new Future.value();
}
/// Prevents further request handlers from running on the response, except for response finalizers.
///
/// To disable response finalizers, see [willCloseItself].
///
/// This method should also set [!isOpen] to true.
void end() {
if (_done?.isCompleted == false) _done.complete();
}
/// Serializes JSON to the response.
void json(value) => this
..contentType = MediaType('application', 'json')
@ -148,7 +139,7 @@ abstract class ResponseContext<RawResponse>
write("$callbackName(${serializer(value)})");
this.contentType =
contentType ?? new MediaType('application', 'javascript');
end();
close();
}
/// Renders a view to the response stream, and closes the response.
@ -160,7 +151,7 @@ abstract class ResponseContext<RawResponse>
..addAll(data ?? <String, dynamic>{}))).then((content) {
write(content);
headers['content-type'] = 'text/html';
end();
close();
});
}
@ -196,7 +187,7 @@ abstract class ResponseContext<RawResponse>
</body>
</html>
''');
end();
close();
}
/// Redirects to the given named [Route].
@ -267,7 +258,7 @@ abstract class ResponseContext<RawResponse>
headers['content-type'] = lookupMimeType(file.path);
buffer.add(file.readAsBytesSync());
end();
close();
}
/// Serializes data to the response.
@ -276,7 +267,7 @@ abstract class ResponseContext<RawResponse>
var text = serializer(value);
if (text.isEmpty) return true;
write(text);
end();
close();
return false;
}
@ -287,14 +278,6 @@ abstract class ResponseContext<RawResponse>
return file.openRead().pipe(this);
}
/// Releases critical resources from the [correspondingRequest].
void releaseCorrespondingRequest() {
if (!correspondingRequest.app.isProduction &&
correspondingRequest.app.logger != null) {
correspondingRequest.container.make<Stopwatch>().stop();
}
}
/// Configure the response to write to an intermediate response buffer, rather than to the stream directly.
void enableBuffer();

View file

@ -151,7 +151,7 @@ class Angel extends Routable {
}
res.write("</ul></body></html>");
res.end();
res.close();
};
@override

View file

@ -273,7 +273,7 @@ class AngelHttp {
res.statusCode = e.statusCode;
handleError =
new Future.sync(() => app.errorHandler(e, req, res)).then((result) {
return app.executeHandler(result, req, res).then((_) => res.end());
return app.executeHandler(result, req, res).then((_) => res.close());
});
}
@ -285,7 +285,15 @@ class AngelHttp {
Future sendResponse(
HttpRequest request, RequestContext req, ResponseContext res,
{bool ignoreFinalizers: false}) {
if (!res.isBuffered) return new Future.value();
void _cleanup(_) {
if (!app.isProduction && app.logger != null) {
var sw = req.container.make<Stopwatch>();
app.logger.info(
"${res.statusCode} ${req.method} ${req.uri} (${sw?.elapsedMilliseconds ?? 'unknown'} ms)");
}
}
if (!res.isBuffered) return res.close().then(_cleanup);
Future finalizers = ignoreFinalizers == true
? new Future.value()
@ -293,7 +301,7 @@ class AngelHttp {
new Future.value(), (out, f) => out.then((_) => f(req, res)));
return finalizers.then((_) {
if (res.isOpen) res.end();
if (res.isOpen) res.close();
for (var key in res.headers.keys) {
request.response.headers.add(key, res.headers[key]);
@ -343,17 +351,7 @@ class AngelHttp {
..cookies.addAll(res.cookies)
..add(outputBuffer);
return request.response.close().then((_) {
if (!app.isProduction && app.logger != null) {
var sw = req.container.make<Stopwatch>();
if (sw.isRunning) {
sw?.stop();
app.logger.info(
"${res.statusCode} ${req.method} ${req.uri} (${sw?.elapsedMilliseconds ?? 'unknown'} ms)");
}
}
});
return request.response.close().then(_cleanup);
});
}

View file

@ -5,6 +5,7 @@ import 'dart:io';
import '../core/core.dart';
import 'http_request_context.dart';
/// An implementation of [ResponseContext] that abstracts over an [HttpResponse].
class HttpResponseContext extends ResponseContext<HttpResponse> {
/// The underlying [HttpResponse] under this instance.
@override
@ -53,21 +54,13 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
..statusCode = statusCode
..cookies.addAll(cookies);
headers.forEach(rawResponse.headers.set);
_isClosed = true;
releaseCorrespondingRequest();
//_isClosed = true;
return _streamInitialized = true;
}
return false;
}
@override
void end() {
_buffer?.lock();
_isClosed = true;
super.end();
}
@override
Future addStream(Stream<List<int>> stream) {
if (_isClosed && isBuffered) throw ResponseContext.closed();
@ -127,6 +120,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
@override
Future close() {
if (!_isClosed) {
if (!isBuffered) {
try {
rawResponse.close();
@ -134,9 +128,13 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
// This only seems to occur on `MockHttpRequest`, but
// this try/catch prevents a crash.
}
} else {
_buffer.lock();
}
_isClosed = true;
}
super.close();
return new Future.value();
}

View file

@ -25,7 +25,7 @@ class QueryService extends Service {
void interceptor(RequestContext req, ResponseContext res) {
res
..write('Middleware')
..end();
..close();
}
void interceptService(RequestContext req, ResponseContext res) {