Make LockableBytesBuilder public
This commit is contained in:
parent
4d980b8e49
commit
582227f99e
3 changed files with 64 additions and 62 deletions
|
@ -2,13 +2,9 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
|
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/runConfigurations/json_dart.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/runConfigurations/templating_dart.xml" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<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$/example/json.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/json.dart" 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/response_context.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/core/response_context.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" />
|
||||||
</list>
|
</list>
|
||||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||||
<ignored path="$PROJECT_DIR$/temp/" />
|
<ignored path="$PROJECT_DIR$/temp/" />
|
||||||
|
@ -31,7 +27,7 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="FileEditorManager">
|
<component name="FileEditorManager">
|
||||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
|
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||||
<state split_layout="SPLIT">
|
<state split_layout="SPLIT">
|
||||||
|
@ -43,11 +39,11 @@
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</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">
|
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="269">
|
<state relative-caret-position="260">
|
||||||
<caret line="118" column="19" selection-start-line="118" selection-start-column="19" selection-end-line="118" selection-end-column="19" />
|
<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>
|
<folding>
|
||||||
<element signature="e#48#68#0" expanded="true" />
|
<element signature="e#48#68#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
@ -55,6 +51,18 @@
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</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" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#0#20#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
</leaf>
|
</leaf>
|
||||||
</component>
|
</component>
|
||||||
<component name="FileTemplateManagerImpl">
|
<component name="FileTemplateManagerImpl">
|
||||||
|
@ -172,7 +180,6 @@
|
||||||
<option value="$PROJECT_DIR$/test/all.dart" />
|
<option value="$PROJECT_DIR$/test/all.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/src/core/angel_base.dart" />
|
<option value="$PROJECT_DIR$/lib/src/core/angel_base.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/src/core/core.dart" />
|
<option value="$PROJECT_DIR$/lib/src/core/core.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/src/http/http_response_context.dart" />
|
|
||||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||||
<option value="$PROJECT_DIR$/test/general_test.dart" />
|
<option value="$PROJECT_DIR$/test/general_test.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/src/core/metadata.dart" />
|
<option value="$PROJECT_DIR$/lib/src/core/metadata.dart" />
|
||||||
|
@ -201,8 +208,9 @@
|
||||||
<option value="$PROJECT_DIR$/example/main.dart" />
|
<option value="$PROJECT_DIR$/example/main.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
|
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
|
||||||
<option value="$PROJECT_DIR$/example/json.dart" />
|
<option value="$PROJECT_DIR$/example/json.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/src/core/response_context.dart" />
|
|
||||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
<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" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
@ -605,14 +613,7 @@
|
||||||
<workItem from="1534009494986" duration="594000" />
|
<workItem from="1534009494986" duration="594000" />
|
||||||
<workItem from="1534546784803" duration="353000" />
|
<workItem from="1534546784803" duration="353000" />
|
||||||
<workItem from="1534547885788" duration="9908000" />
|
<workItem from="1534547885788" duration="9908000" />
|
||||||
<workItem from="1534793956753" duration="7749000" />
|
<workItem from="1534793956753" duration="8159000" />
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00105" summary="Added `Service.findOne` tests">
|
|
||||||
<created>1531408765286</created>
|
|
||||||
<option name="number" value="00105" />
|
|
||||||
<option name="presentableId" value="LOCAL-00105" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1531408765286</updated>
|
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00106" summary="Bump version -> 1.1.5">
|
<task id="LOCAL-00106" summary="Bump version -> 1.1.5">
|
||||||
<created>1531409300283</created>
|
<created>1531409300283</created>
|
||||||
|
@ -950,7 +951,14 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1534813932227</updated>
|
<updated>1534813932227</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="154" />
|
<task id="LOCAL-00154" summary="ResponseContext.isBuffered">
|
||||||
|
<created>1534814859355</created>
|
||||||
|
<option name="number" value="00154" />
|
||||||
|
<option name="presentableId" value="LOCAL-00154" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1534814859355</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="155" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TestHistory">
|
<component name="TestHistory">
|
||||||
|
@ -986,7 +994,7 @@
|
||||||
</history-entry>
|
</history-entry>
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="179956000" />
|
<option name="totallyTimeSpent" value="180366000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TodoView">
|
<component name="TodoView">
|
||||||
<todo-panel id="selected-file">
|
<todo-panel id="selected-file">
|
||||||
|
@ -1049,7 +1057,6 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||||
<MESSAGE value="Remove all usage of dart2_constant" />
|
|
||||||
<MESSAGE value="Add more to parseId" />
|
<MESSAGE value="Add more to parseId" />
|
||||||
<MESSAGE value="Make parseId static + docs" />
|
<MESSAGE value="Make parseId static + docs" />
|
||||||
<MESSAGE value="Make RequestContext generic" />
|
<MESSAGE value="Make RequestContext generic" />
|
||||||
|
@ -1074,7 +1081,8 @@
|
||||||
<MESSAGE value="Routable.use only accepts a Service" />
|
<MESSAGE value="Routable.use only accepts a Service" />
|
||||||
<MESSAGE value="Add flags to Angel constructor" />
|
<MESSAGE value="Add flags to Angel constructor" />
|
||||||
<MESSAGE value="Catch sync errors when using zone" />
|
<MESSAGE value="Catch sync errors when using zone" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Catch sync errors when using zone" />
|
<MESSAGE value="ResponseContext.isBuffered" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="ResponseContext.isBuffered" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
@ -1115,16 +1123,6 @@
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</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="-1368">
|
|
||||||
<caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
|
|
||||||
<folding>
|
|
||||||
<element signature="e#0#20#0" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="69">
|
<state relative-caret-position="69">
|
||||||
|
@ -1443,16 +1441,6 @@
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="269">
|
|
||||||
<caret line="118" column="19" selection-start-line="118" selection-start-column="19" selection-end-line="118" selection-end-column="19" />
|
|
||||||
<folding>
|
|
||||||
<element signature="e#48#68#0" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||||
<state split_layout="SPLIT">
|
<state split_layout="SPLIT">
|
||||||
|
@ -1463,6 +1451,26 @@
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</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>
|
||||||
<component name="masterDetails">
|
<component name="masterDetails">
|
||||||
<states>
|
<states>
|
||||||
|
|
|
@ -52,13 +52,9 @@ abstract class ResponseContext<RawResponse>
|
||||||
Future get done => (_done ?? new Completer()).future;
|
Future get done => (_done ?? new Completer()).future;
|
||||||
|
|
||||||
/// Headers that will be sent to the user.
|
/// Headers that will be sent to the user.
|
||||||
Map<String, String> get headers {
|
///
|
||||||
/// If the response is closed, then this getter will return an immutable `Map`.
|
/// Note that if you have already started writing to the underlying stream, headers will not persist.
|
||||||
if (!isBuffered)
|
Map<String, String> get headers => _headers;
|
||||||
return new Map<String, String>.unmodifiable(_headers);
|
|
||||||
else
|
|
||||||
return _headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Serializes response data into a String.
|
/// Serializes response data into a String.
|
||||||
///
|
///
|
||||||
|
@ -128,10 +124,8 @@ abstract class ResponseContext<RawResponse>
|
||||||
///
|
///
|
||||||
/// This method should be overwritten, setting [streaming] to `false`, **after** a `super` call.
|
/// This method should be overwritten, setting [streaming] to `false`, **after** a `super` call.
|
||||||
Future close() {
|
Future close() {
|
||||||
if (!isBuffered) {
|
if (_buffer is LockableBytesBuilder) {
|
||||||
_buffer?.clear();
|
(_buffer as LockableBytesBuilder).lock();
|
||||||
} else if (_buffer is _LockableBytesBuilder) {
|
|
||||||
(_buffer as _LockableBytesBuilder)._lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_done?.isCompleted == false) _done.complete();
|
if (_done?.isCompleted == false) _done.complete();
|
||||||
|
@ -319,8 +313,8 @@ abstract class ResponseContext<RawResponse>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configure the response to write directly to the output stream, instead of buffering.
|
/// Configure the response to write to an intermediate response buffer, rather than to the stream directly.
|
||||||
bool useStream();
|
void enableBuffer();
|
||||||
|
|
||||||
/// Adds a stream directly the underlying response.
|
/// Adds a stream directly the underlying response.
|
||||||
///
|
///
|
||||||
|
@ -374,15 +368,15 @@ abstract class ResponseContext<RawResponse>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LockableBytesBuilder extends BytesBuilder {
|
abstract class LockableBytesBuilder extends BytesBuilder {
|
||||||
factory _LockableBytesBuilder() {
|
factory LockableBytesBuilder() {
|
||||||
return new _LockableBytesBuilderImpl();
|
return new _LockableBytesBuilderImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _lock();
|
void lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LockableBytesBuilderImpl implements _LockableBytesBuilder {
|
class _LockableBytesBuilderImpl implements LockableBytesBuilder {
|
||||||
final BytesBuilder _buf = new BytesBuilder(copy: false);
|
final BytesBuilder _buf = new BytesBuilder(copy: false);
|
||||||
bool _closed = false;
|
bool _closed = false;
|
||||||
|
|
||||||
|
@ -390,7 +384,7 @@ class _LockableBytesBuilderImpl implements _LockableBytesBuilder {
|
||||||
new StateError('Cannot modified a closed response\'s buffer.');
|
new StateError('Cannot modified a closed response\'s buffer.');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void _lock() {
|
void lock() {
|
||||||
_closed = true;
|
_closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
||||||
Angel app;
|
Angel app;
|
||||||
|
|
||||||
final HttpRequestContext _correspondingRequest;
|
final HttpRequestContext _correspondingRequest;
|
||||||
bool _isClosed = false, _useStream = false;
|
bool _isClosed = false, _useStream = true;
|
||||||
|
|
||||||
HttpResponseContext(this.rawResponse, this.app, [this._correspondingRequest]);
|
HttpResponseContext(this.rawResponse, this.app, [this._correspondingRequest]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue