zmdms-utils 0.0.81 → 0.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/es/validate.js +168 -1
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -1
  4. package/package.json +2 -6
  5. package/src/index.ts +0 -3
  6. package/src/validate.ts +198 -0
  7. package/dist/es/_virtual/FastBufferList.js +0 -7
  8. package/dist/es/_virtual/_commonjs-dynamic-modules.js +0 -5
  9. package/dist/es/_virtual/browser.js +0 -7
  10. package/dist/es/_virtual/browser2.js +0 -7
  11. package/dist/es/_virtual/debug.js +0 -7
  12. package/dist/es/_virtual/event.js +0 -7
  13. package/dist/es/_virtual/http-parser.js +0 -3
  14. package/dist/es/_virtual/iframe.js +0 -7
  15. package/dist/es/_virtual/index.js +0 -7
  16. package/dist/es/_virtual/index2.js +0 -7
  17. package/dist/es/_virtual/index3.js +0 -7
  18. package/dist/es/_virtual/index4.js +0 -7
  19. package/dist/es/_virtual/index5.js +0 -7
  20. package/dist/es/_virtual/index6.js +0 -7
  21. package/dist/es/_virtual/index7.js +0 -3
  22. package/dist/es/_virtual/index8.js +0 -7
  23. package/dist/es/_virtual/index9.js +0 -7
  24. package/dist/es/_virtual/inherits.js +0 -7
  25. package/dist/es/_virtual/inherits_browser.js +0 -7
  26. package/dist/es/_virtual/json3.js +0 -7
  27. package/dist/es/_virtual/node.js +0 -7
  28. package/dist/es/_virtual/node2.js +0 -7
  29. package/dist/es/_virtual/stomp-node.js +0 -3
  30. package/dist/es/_virtual/stomp.js +0 -3
  31. package/dist/es/_virtual/streams.js +0 -3
  32. package/dist/es/_virtual/utils.js +0 -3
  33. package/dist/es/node_modules/bufferutil/fallback.js +0 -43
  34. package/dist/es/node_modules/bufferutil/index.js +0 -21
  35. package/dist/es/node_modules/debug/src/browser.js +0 -192
  36. package/dist/es/node_modules/debug/src/common.js +0 -259
  37. package/dist/es/node_modules/debug/src/index.js +0 -25
  38. package/dist/es/node_modules/debug/src/node.js +0 -192
  39. package/dist/es/node_modules/eventsource/lib/eventsource.js +0 -493
  40. package/dist/es/node_modules/faye-websocket/lib/faye/eventsource.js +0 -150
  41. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event.js +0 -31
  42. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js +0 -41
  43. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api.js +0 -205
  44. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/client.js +0 -107
  45. package/dist/es/node_modules/faye-websocket/lib/faye/websocket.js +0 -47
  46. package/dist/es/node_modules/has-flag/index.js +0 -17
  47. package/dist/es/node_modules/http-parser-js/http-parser.js +0 -471
  48. package/dist/es/node_modules/inherits/inherits.js +0 -14
  49. package/dist/es/node_modules/inherits/inherits_browser.js +0 -38
  50. package/dist/es/node_modules/is-typedarray/index.js +0 -51
  51. package/dist/es/node_modules/json3/lib/json3.js +0 -937
  52. package/dist/es/node_modules/ms/index.js +0 -172
  53. package/dist/es/node_modules/node-gyp-build/index.js +0 -21
  54. package/dist/es/node_modules/node-gyp-build/node-gyp-build.js +0 -222
  55. package/dist/es/node_modules/querystringify/index.js +0 -120
  56. package/dist/es/node_modules/requires-port/index.js +0 -38
  57. package/dist/es/node_modules/safe-buffer/index.js +0 -71
  58. package/dist/es/node_modules/supports-color/index.js +0 -143
  59. package/dist/es/node_modules/typedarray-to-buffer/index.js +0 -37
  60. package/dist/es/node_modules/url-parse/index.js +0 -594
  61. package/dist/es/node_modules/utf-8-validate/fallback.js +0 -71
  62. package/dist/es/node_modules/utf-8-validate/index.js +0 -21
  63. package/dist/es/node_modules/websocket/index.js +0 -15
  64. package/dist/es/node_modules/websocket/lib/Deprecation.js +0 -42
  65. package/dist/es/node_modules/websocket/lib/W3CWebSocket.js +0 -268
  66. package/dist/es/node_modules/websocket/lib/WebSocketClient.js +0 -380
  67. package/dist/es/node_modules/websocket/lib/WebSocketConnection.js +0 -914
  68. package/dist/es/node_modules/websocket/lib/WebSocketFrame.js +0 -293
  69. package/dist/es/node_modules/websocket/lib/WebSocketRequest.js +0 -543
  70. package/dist/es/node_modules/websocket/lib/WebSocketRouter.js +0 -172
  71. package/dist/es/node_modules/websocket/lib/WebSocketRouterRequest.js +0 -67
  72. package/dist/es/node_modules/websocket/lib/WebSocketServer.js +0 -272
  73. package/dist/es/node_modules/websocket/lib/utils.js +0 -80
  74. package/dist/es/node_modules/websocket/lib/version.js +0 -13
  75. package/dist/es/node_modules/websocket/lib/websocket.js +0 -31
  76. package/dist/es/node_modules/websocket/node_modules/debug/src/browser.js +0 -199
  77. package/dist/es/node_modules/websocket/node_modules/debug/src/debug.js +0 -215
  78. package/dist/es/node_modules/websocket/node_modules/debug/src/index.js +0 -25
  79. package/dist/es/node_modules/websocket/node_modules/debug/src/node.js +0 -266
  80. package/dist/es/node_modules/websocket/node_modules/ms/index.js +0 -162
  81. package/dist/es/node_modules/websocket/package.json.js +0 -77
  82. package/dist/es/node_modules/websocket/vendor/FastBufferList.js +0 -205
  83. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/base.js +0 -202
  84. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/client.js +0 -152
  85. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft75.js +0 -128
  86. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft76.js +0 -124
  87. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/headers.js +0 -44
  88. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js +0 -21
  89. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/message.js +0 -37
  90. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi.js +0 -492
  91. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/proxy.js +0 -108
  92. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/server.js +0 -119
  93. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/stream_reader.js +0 -72
  94. package/dist/es/node_modules/websocket-driver/lib/websocket/driver.js +0 -47
  95. package/dist/es/node_modules/websocket-driver/lib/websocket/http_parser.js +0 -140
  96. package/dist/es/node_modules/websocket-driver/lib/websocket/streams.js +0 -150
  97. package/dist/es/node_modules/websocket-extensions/lib/parser.js +0 -103
  98. package/dist/es/node_modules/websocket-extensions/lib/pipeline/cell.js +0 -56
  99. package/dist/es/node_modules/websocket-extensions/lib/pipeline/functor.js +0 -74
  100. package/dist/es/node_modules/websocket-extensions/lib/pipeline/index.js +0 -50
  101. package/dist/es/node_modules/websocket-extensions/lib/pipeline/pledge.js +0 -39
  102. package/dist/es/node_modules/websocket-extensions/lib/pipeline/ring_buffer.js +0 -66
  103. package/dist/es/node_modules/websocket-extensions/lib/websocket_extensions.js +0 -165
  104. package/dist/es/node_modules/yaeti/index.js +0 -17
  105. package/dist/es/node_modules/yaeti/lib/Event.js +0 -24
  106. package/dist/es/node_modules/yaeti/lib/EventTarget.js +0 -130
  107. package/dist/es/node_modules/zt-sockjs-client/lib/entry.js +0 -14
  108. package/dist/es/node_modules/zt-sockjs-client/lib/event/close.js +0 -21
  109. package/dist/es/node_modules/zt-sockjs-client/lib/event/event.js +0 -22
  110. package/dist/es/node_modules/zt-sockjs-client/lib/event/eventtarget.js +0 -62
  111. package/dist/es/node_modules/zt-sockjs-client/lib/event/trans-message.js +0 -19
  112. package/dist/es/node_modules/zt-sockjs-client/lib/facade.js +0 -40
  113. package/dist/es/node_modules/zt-sockjs-client/lib/iframe-bootstrap.js +0 -122
  114. package/dist/es/node_modules/zt-sockjs-client/lib/info-ajax.js +0 -57
  115. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe-receiver.js +0 -50
  116. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe.js +0 -81
  117. package/dist/es/node_modules/zt-sockjs-client/lib/info-receiver.js +0 -101
  118. package/dist/es/node_modules/zt-sockjs-client/lib/location.js +0 -12
  119. package/dist/es/node_modules/zt-sockjs-client/lib/main.js +0 -413
  120. package/dist/es/node_modules/zt-sockjs-client/lib/shims.js +0 -449
  121. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/websocket.js +0 -5
  122. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/xhr.js +0 -80
  123. package/dist/es/node_modules/zt-sockjs-client/lib/transport/eventsource.js +0 -34
  124. package/dist/es/node_modules/zt-sockjs-client/lib/transport/htmlfile.js +0 -31
  125. package/dist/es/node_modules/zt-sockjs-client/lib/transport/iframe.js +0 -154
  126. package/dist/es/node_modules/zt-sockjs-client/lib/transport/jsonp-polling.js +0 -41
  127. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/ajax-based.js +0 -55
  128. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/buffered-sender.js +0 -92
  129. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/iframe-wrap.js +0 -39
  130. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/polling.js +0 -65
  131. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/sender-receiver.js +0 -52
  132. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/eventsource.js +0 -69
  133. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/htmlfile.js +0 -96
  134. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/jsonp.js +0 -193
  135. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/xhr.js +0 -75
  136. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/jsonp.js +0 -104
  137. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xdr.js +0 -113
  138. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-cors.js +0 -19
  139. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-fake.js +0 -28
  140. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-local.js +0 -21
  141. package/dist/es/node_modules/zt-sockjs-client/lib/transport/websocket.js +0 -108
  142. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-polling.js +0 -30
  143. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-streaming.js +0 -38
  144. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-polling.js +0 -40
  145. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-streaming.js +0 -50
  146. package/dist/es/node_modules/zt-sockjs-client/lib/transport-list.js +0 -28
  147. package/dist/es/node_modules/zt-sockjs-client/lib/utils/browser.js +0 -29
  148. package/dist/es/node_modules/zt-sockjs-client/lib/utils/escape.js +0 -53
  149. package/dist/es/node_modules/zt-sockjs-client/lib/utils/event.js +0 -78
  150. package/dist/es/node_modules/zt-sockjs-client/lib/utils/iframe.js +0 -205
  151. package/dist/es/node_modules/zt-sockjs-client/lib/utils/log.js +0 -20
  152. package/dist/es/node_modules/zt-sockjs-client/lib/utils/object.js +0 -24
  153. package/dist/es/node_modules/zt-sockjs-client/lib/utils/random.js +0 -30
  154. package/dist/es/node_modules/zt-sockjs-client/lib/utils/transport.js +0 -52
  155. package/dist/es/node_modules/zt-sockjs-client/lib/utils/url.js +0 -54
  156. package/dist/es/node_modules/zt-sockjs-client/lib/version.js +0 -11
  157. package/dist/es/node_modules/zt-stompjs/index.js +0 -23
  158. package/dist/es/node_modules/zt-stompjs/lib/stomp-node.js +0 -117
  159. package/dist/es/node_modules/zt-stompjs/lib/stomp.js +0 -536
  160. package/dist/es/stompClient.d.ts +0 -55
  161. package/dist/es/stompClient.js +0 -379
  162. package/src/stompClient.ts +0 -449
@@ -1,471 +0,0 @@
1
- import { __exports as httpParser } from '../../_virtual/http-parser.js';
2
-
3
- /*jshint node:true */
4
- httpParser.HTTPParser = HTTPParser;
5
- function HTTPParser(type) {
6
- if (type !== undefined && type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
7
- throw new Error('type must be REQUEST or RESPONSE');
8
- }
9
- if (type === undefined) ; else {
10
- this.initialize(type);
11
- }
12
- this.maxHeaderSize=HTTPParser.maxHeaderSize;
13
- }
14
- HTTPParser.prototype.initialize = function (type, async_resource) {
15
- if (type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
16
- throw new Error('type must be REQUEST or RESPONSE');
17
- }
18
- this.type = type;
19
- this.state = type + '_LINE';
20
- this.info = {
21
- headers: [],
22
- upgrade: false
23
- };
24
- this.trailers = [];
25
- this.line = '';
26
- this.isChunked = false;
27
- this.connection = '';
28
- this.headerSize = 0; // for preventing too big headers
29
- this.body_bytes = null;
30
- this.isUserCall = false;
31
- this.hadError = false;
32
- };
33
-
34
- HTTPParser.encoding = 'ascii';
35
- HTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;
36
- HTTPParser.REQUEST = 'REQUEST';
37
- HTTPParser.RESPONSE = 'RESPONSE';
38
-
39
- // Note: *not* starting with kOnHeaders=0 line the Node parser, because any
40
- // newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!
41
- var kOnHeaders = HTTPParser.kOnHeaders = 1;
42
- var kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;
43
- var kOnBody = HTTPParser.kOnBody = 3;
44
- var kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;
45
-
46
- // Some handler stubs, needed for compatibility
47
- HTTPParser.prototype[kOnHeaders] =
48
- HTTPParser.prototype[kOnHeadersComplete] =
49
- HTTPParser.prototype[kOnBody] =
50
- HTTPParser.prototype[kOnMessageComplete] = function () {};
51
-
52
- var compatMode0_12 = true;
53
- Object.defineProperty(HTTPParser, 'kOnExecute', {
54
- get: function () {
55
- // hack for backward compatibility
56
- compatMode0_12 = false;
57
- return 99;
58
- }
59
- });
60
-
61
- var methods = httpParser.methods = HTTPParser.methods = [
62
- 'DELETE',
63
- 'GET',
64
- 'HEAD',
65
- 'POST',
66
- 'PUT',
67
- 'CONNECT',
68
- 'OPTIONS',
69
- 'TRACE',
70
- 'COPY',
71
- 'LOCK',
72
- 'MKCOL',
73
- 'MOVE',
74
- 'PROPFIND',
75
- 'PROPPATCH',
76
- 'SEARCH',
77
- 'UNLOCK',
78
- 'BIND',
79
- 'REBIND',
80
- 'UNBIND',
81
- 'ACL',
82
- 'REPORT',
83
- 'MKACTIVITY',
84
- 'CHECKOUT',
85
- 'MERGE',
86
- 'M-SEARCH',
87
- 'NOTIFY',
88
- 'SUBSCRIBE',
89
- 'UNSUBSCRIBE',
90
- 'PATCH',
91
- 'PURGE',
92
- 'MKCALENDAR',
93
- 'LINK',
94
- 'UNLINK',
95
- 'SOURCE',
96
- ];
97
- var method_connect = methods.indexOf('CONNECT');
98
- HTTPParser.prototype.reinitialize = HTTPParser;
99
- HTTPParser.prototype.close =
100
- HTTPParser.prototype.pause =
101
- HTTPParser.prototype.resume =
102
- HTTPParser.prototype.remove =
103
- HTTPParser.prototype.free = function () {};
104
- HTTPParser.prototype._compatMode0_11 = false;
105
- HTTPParser.prototype.getAsyncId = function() { return 0; };
106
-
107
- var headerState = {
108
- REQUEST_LINE: true,
109
- RESPONSE_LINE: true,
110
- HEADER: true
111
- };
112
- HTTPParser.prototype.execute = function (chunk, start, length) {
113
- if (!(this instanceof HTTPParser)) {
114
- throw new TypeError('not a HTTPParser');
115
- }
116
-
117
- // backward compat to node < 0.11.4
118
- // Note: the start and length params were removed in newer version
119
- start = start || 0;
120
- length = typeof length === 'number' ? length : chunk.length;
121
-
122
- this.chunk = chunk;
123
- this.offset = start;
124
- var end = this.end = start + length;
125
- try {
126
- while (this.offset < end) {
127
- if (this[this.state]()) {
128
- break;
129
- }
130
- }
131
- } catch (err) {
132
- if (this.isUserCall) {
133
- throw err;
134
- }
135
- this.hadError = true;
136
- return err;
137
- }
138
- this.chunk = null;
139
- length = this.offset - start;
140
- if (headerState[this.state]) {
141
- this.headerSize += length;
142
- if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {
143
- return new Error('max header size exceeded');
144
- }
145
- }
146
- return length;
147
- };
148
-
149
- var stateFinishAllowed = {
150
- REQUEST_LINE: true,
151
- RESPONSE_LINE: true,
152
- BODY_RAW: true
153
- };
154
- HTTPParser.prototype.finish = function () {
155
- if (this.hadError) {
156
- return;
157
- }
158
- if (!stateFinishAllowed[this.state]) {
159
- return new Error('invalid state for EOF');
160
- }
161
- if (this.state === 'BODY_RAW') {
162
- this.userCall()(this[kOnMessageComplete]());
163
- }
164
- };
165
-
166
- // These three methods are used for an internal speed optimization, and it also
167
- // works if theses are noops. Basically consume() asks us to read the bytes
168
- // ourselves, but if we don't do it we get them through execute().
169
- HTTPParser.prototype.consume =
170
- HTTPParser.prototype.unconsume =
171
- HTTPParser.prototype.getCurrentBuffer = function () {};
172
-
173
- //For correct error handling - see HTTPParser#execute
174
- //Usage: this.userCall()(userFunction('arg'));
175
- HTTPParser.prototype.userCall = function () {
176
- this.isUserCall = true;
177
- var self = this;
178
- return function (ret) {
179
- self.isUserCall = false;
180
- return ret;
181
- };
182
- };
183
-
184
- HTTPParser.prototype.nextRequest = function () {
185
- this.userCall()(this[kOnMessageComplete]());
186
- this.reinitialize(this.type);
187
- };
188
-
189
- HTTPParser.prototype.consumeLine = function () {
190
- var end = this.end,
191
- chunk = this.chunk;
192
- for (var i = this.offset; i < end; i++) {
193
- if (chunk[i] === 0x0a) { // \n
194
- var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);
195
- if (line.charAt(line.length - 1) === '\r') {
196
- line = line.substr(0, line.length - 1);
197
- }
198
- this.line = '';
199
- this.offset = i + 1;
200
- return line;
201
- }
202
- }
203
- //line split over multiple chunks
204
- this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);
205
- this.offset = this.end;
206
- };
207
-
208
- var headerExp = /^([^: \t]+):[ \t]*((?:.*[^ \t])|)/;
209
- var headerContinueExp = /^[ \t]+(.*[^ \t])/;
210
- HTTPParser.prototype.parseHeader = function (line, headers) {
211
- if (line.indexOf('\r') !== -1) {
212
- throw parseErrorCode('HPE_LF_EXPECTED');
213
- }
214
-
215
- var match = headerExp.exec(line);
216
- var k = match && match[1];
217
- if (k) { // skip empty string (malformed header)
218
- headers.push(k);
219
- headers.push(match[2]);
220
- } else {
221
- var matchContinue = headerContinueExp.exec(line);
222
- if (matchContinue && headers.length) {
223
- if (headers[headers.length - 1]) {
224
- headers[headers.length - 1] += ' ';
225
- }
226
- headers[headers.length - 1] += matchContinue[1];
227
- }
228
- }
229
- };
230
-
231
- var requestExp = /^([A-Z-]+) ([^ ]+) HTTP\/(\d)\.(\d)$/;
232
- HTTPParser.prototype.REQUEST_LINE = function () {
233
- var line = this.consumeLine();
234
- if (!line) {
235
- return;
236
- }
237
- var match = requestExp.exec(line);
238
- if (match === null) {
239
- throw parseErrorCode('HPE_INVALID_CONSTANT');
240
- }
241
- this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);
242
- if (this.info.method === -1) {
243
- throw new Error('invalid request method');
244
- }
245
- this.info.url = match[2];
246
- this.info.versionMajor = +match[3];
247
- this.info.versionMinor = +match[4];
248
- this.body_bytes = 0;
249
- this.state = 'HEADER';
250
- };
251
-
252
- var responseExp = /^HTTP\/(\d)\.(\d) (\d{3}) ?(.*)$/;
253
- HTTPParser.prototype.RESPONSE_LINE = function () {
254
- var line = this.consumeLine();
255
- if (!line) {
256
- return;
257
- }
258
- var match = responseExp.exec(line);
259
- if (match === null) {
260
- throw parseErrorCode('HPE_INVALID_CONSTANT');
261
- }
262
- this.info.versionMajor = +match[1];
263
- this.info.versionMinor = +match[2];
264
- var statusCode = this.info.statusCode = +match[3];
265
- this.info.statusMessage = match[4];
266
- // Implied zero length.
267
- if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {
268
- this.body_bytes = 0;
269
- }
270
- this.state = 'HEADER';
271
- };
272
-
273
- HTTPParser.prototype.shouldKeepAlive = function () {
274
- if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {
275
- if (this.connection.indexOf('close') !== -1) {
276
- return false;
277
- }
278
- } else if (this.connection.indexOf('keep-alive') === -1) {
279
- return false;
280
- }
281
- if (this.body_bytes !== null || this.isChunked) { // || skipBody
282
- return true;
283
- }
284
- return false;
285
- };
286
-
287
- HTTPParser.prototype.HEADER = function () {
288
- var line = this.consumeLine();
289
- if (line === undefined) {
290
- return;
291
- }
292
- var info = this.info;
293
- if (line) {
294
- this.parseHeader(line, info.headers);
295
- } else {
296
- var headers = info.headers;
297
- var hasContentLength = false;
298
- var currentContentLengthValue;
299
- var hasUpgradeHeader = false;
300
- for (var i = 0; i < headers.length; i += 2) {
301
- switch (headers[i].toLowerCase()) {
302
- case 'transfer-encoding':
303
- this.isChunked = headers[i + 1].toLowerCase() === 'chunked';
304
- break;
305
- case 'content-length':
306
- currentContentLengthValue = +headers[i + 1];
307
- if (hasContentLength) {
308
- // Fix duplicate Content-Length header with same values.
309
- // Throw error only if values are different.
310
- // Known issues:
311
- // https://github.com/request/request/issues/2091#issuecomment-328715113
312
- // https://github.com/nodejs/node/issues/6517#issuecomment-216263771
313
- if (currentContentLengthValue !== this.body_bytes) {
314
- throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');
315
- }
316
- } else {
317
- hasContentLength = true;
318
- this.body_bytes = currentContentLengthValue;
319
- }
320
- break;
321
- case 'connection':
322
- this.connection += headers[i + 1].toLowerCase();
323
- break;
324
- case 'upgrade':
325
- hasUpgradeHeader = true;
326
- break;
327
- }
328
- }
329
-
330
- // if both isChunked and hasContentLength, isChunked wins
331
- // This is required so the body is parsed using the chunked method, and matches
332
- // Chrome's behavior. We could, maybe, ignore them both (would get chunked
333
- // encoding into the body), and/or disable shouldKeepAlive to be more
334
- // resilient.
335
- if (this.isChunked && hasContentLength) {
336
- hasContentLength = false;
337
- this.body_bytes = null;
338
- }
339
-
340
- // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737
341
- // "For responses, "Upgrade: foo" and "Connection: upgrade" are
342
- // mandatory only when it is a 101 Switching Protocols response,
343
- // otherwise it is purely informational, to announce support.
344
- if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {
345
- info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;
346
- } else {
347
- info.upgrade = info.method === method_connect;
348
- }
349
-
350
- if (this.isChunked && info.upgrade) {
351
- this.isChunked = false;
352
- }
353
-
354
- info.shouldKeepAlive = this.shouldKeepAlive();
355
- //problem which also exists in original node: we should know skipBody before calling onHeadersComplete
356
- var skipBody;
357
- if (compatMode0_12) {
358
- skipBody = this.userCall()(this[kOnHeadersComplete](info));
359
- } else {
360
- skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,
361
- info.versionMinor, info.headers, info.method, info.url, info.statusCode,
362
- info.statusMessage, info.upgrade, info.shouldKeepAlive));
363
- }
364
- if (skipBody === 2) {
365
- this.nextRequest();
366
- return true;
367
- } else if (this.isChunked && !skipBody) {
368
- this.state = 'BODY_CHUNKHEAD';
369
- } else if (skipBody || this.body_bytes === 0) {
370
- this.nextRequest();
371
- // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,
372
- // need this "return true;" if it's an upgrade request.
373
- return info.upgrade;
374
- } else if (this.body_bytes === null) {
375
- this.state = 'BODY_RAW';
376
- } else {
377
- this.state = 'BODY_SIZED';
378
- }
379
- }
380
- };
381
-
382
- HTTPParser.prototype.BODY_CHUNKHEAD = function () {
383
- var line = this.consumeLine();
384
- if (line === undefined) {
385
- return;
386
- }
387
- this.body_bytes = parseInt(line, 16);
388
- if (!this.body_bytes) {
389
- this.state = 'BODY_CHUNKTRAILERS';
390
- } else {
391
- this.state = 'BODY_CHUNK';
392
- }
393
- };
394
-
395
- HTTPParser.prototype.BODY_CHUNK = function () {
396
- var length = Math.min(this.end - this.offset, this.body_bytes);
397
- // 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
398
- this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.offset + length), 0, length));
399
- this.offset += length;
400
- this.body_bytes -= length;
401
- if (!this.body_bytes) {
402
- this.state = 'BODY_CHUNKEMPTYLINE';
403
- }
404
- };
405
-
406
- HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {
407
- var line = this.consumeLine();
408
- if (line === undefined) {
409
- return;
410
- }
411
- if (line !== '') {
412
- throw new Error('Expected empty line');
413
- }
414
- this.state = 'BODY_CHUNKHEAD';
415
- };
416
-
417
- HTTPParser.prototype.BODY_CHUNKTRAILERS = function () {
418
- var line = this.consumeLine();
419
- if (line === undefined) {
420
- return;
421
- }
422
- if (line) {
423
- this.parseHeader(line, this.trailers);
424
- } else {
425
- if (this.trailers.length) {
426
- this.userCall()(this[kOnHeaders](this.trailers, ''));
427
- }
428
- this.nextRequest();
429
- }
430
- };
431
-
432
- HTTPParser.prototype.BODY_RAW = function () {
433
- // 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
434
- this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.end), 0, this.end - this.offset));
435
- this.offset = this.end;
436
- };
437
-
438
- HTTPParser.prototype.BODY_SIZED = function () {
439
- var length = Math.min(this.end - this.offset, this.body_bytes);
440
- // 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
441
- this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.offset + length), 0, length));
442
- this.offset += length;
443
- this.body_bytes -= length;
444
- if (!this.body_bytes) {
445
- this.nextRequest();
446
- }
447
- };
448
-
449
- // backward compat to node < 0.11.6
450
- ['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {
451
- var k = HTTPParser['kOn' + name];
452
- Object.defineProperty(HTTPParser.prototype, 'on' + name, {
453
- get: function () {
454
- return this[k];
455
- },
456
- set: function (to) {
457
- // hack for backward compatibility
458
- this._compatMode0_11 = true;
459
- method_connect = 'CONNECT';
460
- return (this[k] = to);
461
- }
462
- });
463
- });
464
-
465
- function parseErrorCode(code) {
466
- var err = new Error('Parse Error');
467
- err.code = code;
468
- return err;
469
- }
470
-
471
- export { httpParser as default };
@@ -1,14 +0,0 @@
1
- import { __module as inherits } from '../../_virtual/inherits.js';
2
- import { __require as requireInherits_browser } from './inherits_browser.js';
3
-
4
- (function (module) {
5
- try {
6
- var util = require('util');
7
- /* istanbul ignore next */
8
- if (typeof util.inherits !== 'function') throw '';
9
- module.exports = util.inherits;
10
- } catch (e) {
11
- /* istanbul ignore next */
12
- module.exports = requireInherits_browser();
13
- }
14
- } (inherits));
@@ -1,38 +0,0 @@
1
- import { exports as inherits_browserExports, __module as inherits_browser } from '../../_virtual/inherits_browser.js';
2
-
3
- var hasRequiredInherits_browser;
4
-
5
- function requireInherits_browser () {
6
- if (hasRequiredInherits_browser) return inherits_browserExports;
7
- hasRequiredInherits_browser = 1;
8
- if (typeof Object.create === 'function') {
9
- // implementation from standard node.js 'util' module
10
- inherits_browser.exports = function inherits(ctor, superCtor) {
11
- if (superCtor) {
12
- ctor.super_ = superCtor;
13
- ctor.prototype = Object.create(superCtor.prototype, {
14
- constructor: {
15
- value: ctor,
16
- enumerable: false,
17
- writable: true,
18
- configurable: true
19
- }
20
- });
21
- }
22
- };
23
- } else {
24
- // old school shim for old browsers
25
- inherits_browser.exports = function inherits(ctor, superCtor) {
26
- if (superCtor) {
27
- ctor.super_ = superCtor;
28
- var TempCtor = function () {};
29
- TempCtor.prototype = superCtor.prototype;
30
- ctor.prototype = new TempCtor();
31
- ctor.prototype.constructor = ctor;
32
- }
33
- };
34
- }
35
- return inherits_browserExports;
36
- }
37
-
38
- export { requireInherits_browser as __require };
@@ -1,51 +0,0 @@
1
- var isTypedarray;
2
- var hasRequiredIsTypedarray;
3
-
4
- function requireIsTypedarray () {
5
- if (hasRequiredIsTypedarray) return isTypedarray;
6
- hasRequiredIsTypedarray = 1;
7
- isTypedarray = isTypedArray;
8
- isTypedArray.strict = isStrictTypedArray;
9
- isTypedArray.loose = isLooseTypedArray;
10
-
11
- var toString = Object.prototype.toString;
12
- var names = {
13
- '[object Int8Array]': true
14
- , '[object Int16Array]': true
15
- , '[object Int32Array]': true
16
- , '[object Uint8Array]': true
17
- , '[object Uint8ClampedArray]': true
18
- , '[object Uint16Array]': true
19
- , '[object Uint32Array]': true
20
- , '[object Float32Array]': true
21
- , '[object Float64Array]': true
22
- };
23
-
24
- function isTypedArray(arr) {
25
- return (
26
- isStrictTypedArray(arr)
27
- || isLooseTypedArray(arr)
28
- )
29
- }
30
-
31
- function isStrictTypedArray(arr) {
32
- return (
33
- arr instanceof Int8Array
34
- || arr instanceof Int16Array
35
- || arr instanceof Int32Array
36
- || arr instanceof Uint8Array
37
- || arr instanceof Uint8ClampedArray
38
- || arr instanceof Uint16Array
39
- || arr instanceof Uint32Array
40
- || arr instanceof Float32Array
41
- || arr instanceof Float64Array
42
- )
43
- }
44
-
45
- function isLooseTypedArray(arr) {
46
- return names[toString.call(arr)]
47
- }
48
- return isTypedarray;
49
- }
50
-
51
- export { requireIsTypedarray as __require };