mirror of https://github.com/grpc/grpc-web.git
Internal code sync
This commit is contained in:
parent
7984205077
commit
7afe497d8f
|
|
@ -1,6 +1,7 @@
|
|||
goog.module('grpc.web.ClientOptions');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
const XmlHttpFactory = goog.requireType('goog.net.XmlHttpFactory');
|
||||
const {StreamInterceptor, UnaryInterceptor} = goog.require('grpc.web.Interceptor');
|
||||
|
||||
|
||||
|
|
@ -44,6 +45,20 @@ class ClientOptions {
|
|||
* @type {string|undefined}
|
||||
*/
|
||||
this.format;
|
||||
|
||||
/**
|
||||
* The XmlHttpFactory for server-streaming calls.
|
||||
* Example: use 'goog.net.FetchXmlHttpFactory' to reduce memory consumption
|
||||
* during high throughput server-streaming calls.
|
||||
* <pre>
|
||||
* ...
|
||||
*
|
||||
* const xmlHttpFactory =
|
||||
* new FetchXmlHttpFactory({streamBinaryChunks: true});
|
||||
* </pre>
|
||||
* @type {!XmlHttpFactory|undefined}
|
||||
*/
|
||||
this.streamingXmlHttpFactory;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,13 +98,13 @@ class StreamBodyClientReadableStream {
|
|||
|
||||
/**
|
||||
* @private
|
||||
* @const {!Array<function(...):?>} The list of stream end callback
|
||||
* @const {!Array<function(...)>} The list of stream end callback
|
||||
*/
|
||||
this.onEndCallbacks_ = [];
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @const {!Array<function(...):?>} The list of error callback
|
||||
* @const {!Array<function(!GrpcWebError)>} The list of error callback
|
||||
*/
|
||||
this.onErrorCallbacks_ = [];
|
||||
|
||||
|
|
@ -138,8 +138,8 @@ class StreamBodyClientReadableStream {
|
|||
}
|
||||
const responseMessage = this.grpcResponseDeserializeFn_(response);
|
||||
const grpcStatus = StatusCode.fromHttpStatus(this.xhr_.getStatus());
|
||||
this.sendMetadataCallbacks_(this.readHeaders_());
|
||||
if (grpcStatus == StatusCode.OK) {
|
||||
this.sendMetadataCallbacks_(this.readHeaders_());
|
||||
this.sendDataCallbacks_(responseMessage);
|
||||
} else {
|
||||
this.sendErrorCallbacks_(
|
||||
|
|
@ -174,6 +174,7 @@ class StreamBodyClientReadableStream {
|
|||
this.xhr_.getLastErrorCode() +
|
||||
', error: ' + this.xhr_.getLastError();
|
||||
}
|
||||
this.sendMetadataCallbacks_(this.readHeaders_());
|
||||
this.sendErrorCallbacks_({
|
||||
code: code,
|
||||
message: message,
|
||||
|
|
@ -407,7 +408,7 @@ class StreamBodyClientReadableStream {
|
|||
|
||||
/**
|
||||
* @private
|
||||
* @param {?} error The error to send back
|
||||
* @param {!GrpcWebError} error The error to send back
|
||||
*/
|
||||
sendErrorCallbacks_(error) {
|
||||
for (let i = 0; i < this.onErrorCallbacks_.length; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue