Skip to content

Commit 5ecdc7d

Browse files
committed
Make payload limit configurable by tests
1 parent 2e2270d commit 5ecdc7d

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/common/parser/ApcParser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ export class ApcParser implements IApcParser {
199199
* as APC handlers.
200200
*/
201201
export class ApcHandler implements IApcHandler {
202+
private static PAYLOAD_LIMIT = PAYLOAD_LIMIT;
203+
202204
private _data = '';
203205
private _hitLimit: boolean = false;
204206

@@ -214,7 +216,7 @@ export class ApcHandler implements IApcHandler {
214216
return;
215217
}
216218
this._data += utf32ToString(data, start, end);
217-
if (this._data.length > PAYLOAD_LIMIT) {
219+
if (this._data.length > ApcHandler.PAYLOAD_LIMIT) {
218220
this._data = '';
219221
this._hitLimit = true;
220222
}

src/common/parser/DcsParser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ EMPTY_PARAMS.addParam(0);
138138
* Note: The payload is currently limited to 50 MB (hardcoded).
139139
*/
140140
export class DcsHandler implements IDcsHandler {
141+
private static PAYLOAD_LIMIT = PAYLOAD_LIMIT;
142+
141143
private _data = '';
142144
private _params: IParams = EMPTY_PARAMS;
143145
private _hitLimit: boolean = false;
@@ -159,7 +161,7 @@ export class DcsHandler implements IDcsHandler {
159161
return;
160162
}
161163
this._data += utf32ToString(data, start, end);
162-
if (this._data.length > PAYLOAD_LIMIT) {
164+
if (this._data.length > DcsHandler.PAYLOAD_LIMIT) {
163165
this._data = '';
164166
this._hitLimit = true;
165167
}

src/common/parser/OscParser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ export class OscParser implements IOscParser {
192192
* as OSC handlers.
193193
*/
194194
export class OscHandler implements IOscHandler {
195+
private static PAYLOAD_LIMIT = PAYLOAD_LIMIT;
196+
195197
private _data = '';
196198
private _hitLimit: boolean = false;
197199

@@ -207,7 +209,7 @@ export class OscHandler implements IOscHandler {
207209
return;
208210
}
209211
this._data += utf32ToString(data, start, end);
210-
if (this._data.length > PAYLOAD_LIMIT) {
212+
if (this._data.length > OscHandler.PAYLOAD_LIMIT) {
211213
this._data = '';
212214
this._hitLimit = true;
213215
}

0 commit comments

Comments
 (0)