-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow GrpcWebStreamParser to accept Uint8Array #734
Changes from 2 commits
cc99c88
c1c4a69
85985a5
ee18e8e
329b736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,16 +175,28 @@ Parser.prototype.error_ = function(inputBytes, pos, errorMsg) { | |
|
||
|
||
/** | ||
* Parse the new input. | ||
* | ||
* Note that there is no Parser state to indicate the end of a stream. | ||
* | ||
* @param {string|!ArrayBuffer|!Uint8Array|!Array<number>} input The input data | ||
* @throws {!Error} Throws an error message if the input is invalid. | ||
* @override | ||
* @return {?Array<string|!Object>} any parsed objects (atomic messages) | ||
* in an array, or null if more data needs be read to parse any new object. | ||
*/ | ||
GrpcWebStreamParser.prototype.parse = function(input) { | ||
asserts.assert(input instanceof Array || input instanceof ArrayBuffer); | ||
asserts.assert(input instanceof Array || input instanceof ArrayBuffer || input instanceof Uint8Array); | ||
|
||
var parser = this; | ||
var inputBytes = (input instanceof Array) ? input : new Uint8Array(input); | ||
var inputBytes; | ||
var pos = 0; | ||
|
||
if (input instanceof Uint8Array || input instanceof Array) { | ||
inputBytes = input | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing semicolon. doesn't pass closure lint checks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
} else { | ||
inputBytes = new Uint8Array(input) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing semicolon. doesn't pass closure lint checks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
} | ||
|
||
while (pos < inputBytes.length) { | ||
switch (parser.state_) { | ||
case Parser.State_.INVALID: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry another issue: apparently you need
@override
here because now the spec differsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed