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('grpc.web.ClientOptions');
|
||||||
goog.module.declareLegacyNamespace();
|
goog.module.declareLegacyNamespace();
|
||||||
|
|
||||||
|
const XmlHttpFactory = goog.requireType('goog.net.XmlHttpFactory');
|
||||||
const {StreamInterceptor, UnaryInterceptor} = goog.require('grpc.web.Interceptor');
|
const {StreamInterceptor, UnaryInterceptor} = goog.require('grpc.web.Interceptor');
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,6 +45,20 @@ class ClientOptions {
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.format;
|
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
|
* @private
|
||||||
* @const {!Array<function(...):?>} The list of stream end callback
|
* @const {!Array<function(...)>} The list of stream end callback
|
||||||
*/
|
*/
|
||||||
this.onEndCallbacks_ = [];
|
this.onEndCallbacks_ = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @const {!Array<function(...):?>} The list of error callback
|
* @const {!Array<function(!GrpcWebError)>} The list of error callback
|
||||||
*/
|
*/
|
||||||
this.onErrorCallbacks_ = [];
|
this.onErrorCallbacks_ = [];
|
||||||
|
|
||||||
|
|
@ -138,8 +138,8 @@ class StreamBodyClientReadableStream {
|
||||||
}
|
}
|
||||||
const responseMessage = this.grpcResponseDeserializeFn_(response);
|
const responseMessage = this.grpcResponseDeserializeFn_(response);
|
||||||
const grpcStatus = StatusCode.fromHttpStatus(this.xhr_.getStatus());
|
const grpcStatus = StatusCode.fromHttpStatus(this.xhr_.getStatus());
|
||||||
if (grpcStatus == StatusCode.OK) {
|
|
||||||
this.sendMetadataCallbacks_(this.readHeaders_());
|
this.sendMetadataCallbacks_(this.readHeaders_());
|
||||||
|
if (grpcStatus == StatusCode.OK) {
|
||||||
this.sendDataCallbacks_(responseMessage);
|
this.sendDataCallbacks_(responseMessage);
|
||||||
} else {
|
} else {
|
||||||
this.sendErrorCallbacks_(
|
this.sendErrorCallbacks_(
|
||||||
|
|
@ -174,6 +174,7 @@ class StreamBodyClientReadableStream {
|
||||||
this.xhr_.getLastErrorCode() +
|
this.xhr_.getLastErrorCode() +
|
||||||
', error: ' + this.xhr_.getLastError();
|
', error: ' + this.xhr_.getLastError();
|
||||||
}
|
}
|
||||||
|
this.sendMetadataCallbacks_(this.readHeaders_());
|
||||||
this.sendErrorCallbacks_({
|
this.sendErrorCallbacks_({
|
||||||
code: code,
|
code: code,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
@ -407,7 +408,7 @@ class StreamBodyClientReadableStream {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {?} error The error to send back
|
* @param {!GrpcWebError} error The error to send back
|
||||||
*/
|
*/
|
||||||
sendErrorCallbacks_(error) {
|
sendErrorCallbacks_(error) {
|
||||||
for (let i = 0; i < this.onErrorCallbacks_.length; i++) {
|
for (let i = 0; i < this.onErrorCallbacks_.length; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue