UNPKG

24.3 kBJavaScriptView Raw
1/**
2 * Copyright 2017 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16const EventEmitter = require('events');
17const {helper, debugError} = require('./helper');
18const Multimap = require('./Multimap');
19
20class NetworkManager extends EventEmitter {
21 /**
22 * @param {!Puppeteer.CDPSession} client
23 * @param {!Puppeteer.FrameManager} frameManager
24 */
25 constructor(client, frameManager) {
26 super();
27 this._client = client;
28 this._frameManager = frameManager;
29 /** @type {!Map<string, !Request>} */
30 this._requestIdToRequest = new Map();
31 /** @type {!Map<string, !Request>} */
32 this._interceptionIdToRequest = new Map();
33 /** @type {!Object<string, string>} */
34 this._extraHTTPHeaders = {};
35
36 this._offline = false;
37
38 /** @type {?{username: string, password: string}} */
39 this._credentials = null;
40 /** @type {!Set<string>} */
41 this._attemptedAuthentications = new Set();
42 this._userRequestInterceptionEnabled = false;
43 this._protocolRequestInterceptionEnabled = false;
44 /** @type {!Multimap} */
45 this._requestHashToRequestIds = new Multimap();
46 /** @type {!Multimap} */
47 this._requestHashToInterceptionIds = new Multimap();
48
49 this._client.on('Network.requestWillBeSent', this._onRequestWillBeSent.bind(this));
50 this._client.on('Network.requestIntercepted', this._onRequestIntercepted.bind(this));
51 this._client.on('Network.requestServedFromCache', this._onRequestServedFromCache.bind(this));
52 this._client.on('Network.responseReceived', this._onResponseReceived.bind(this));
53 this._client.on('Network.loadingFinished', this._onLoadingFinished.bind(this));
54 this._client.on('Network.loadingFailed', this._onLoadingFailed.bind(this));
55 }
56
57 /**
58 * @param {?{username: string, password: string}} credentials
59 */
60 async authenticate(credentials) {
61 this._credentials = credentials;
62 await this._updateProtocolRequestInterception();
63 }
64
65 /**
66 * @param {!Object<string, string>} extraHTTPHeaders
67 */
68 async setExtraHTTPHeaders(extraHTTPHeaders) {
69 this._extraHTTPHeaders = {};
70 for (const key of Object.keys(extraHTTPHeaders)) {
71 const value = extraHTTPHeaders[key];
72 console.assert(helper.isString(value), `Expected value of header "${key}" to be String, but "${typeof value}" is found.`);
73 this._extraHTTPHeaders[key.toLowerCase()] = value;
74 }
75 await this._client.send('Network.setExtraHTTPHeaders', { headers: this._extraHTTPHeaders });
76 }
77
78 /**
79 * @return {!Object<string, string>}
80 */
81 extraHTTPHeaders() {
82 return Object.assign({}, this._extraHTTPHeaders);
83 }
84
85 /**
86 * @param {boolean} value
87 */
88 async setOfflineMode(value) {
89 if (this._offline === value)
90 return;
91 this._offline = value;
92 await this._client.send('Network.emulateNetworkConditions', {
93 offline: this._offline,
94 // values of 0 remove any active throttling. crbug.com/456324#c9
95 latency: 0,
96 downloadThroughput: -1,
97 uploadThroughput: -1
98 });
99 }
100
101 /**
102 * @param {string} userAgent
103 */
104 async setUserAgent(userAgent) {
105 await this._client.send('Network.setUserAgentOverride', { userAgent });
106 }
107
108 /**
109 * @param {boolean} value
110 */
111 async setRequestInterception(value) {
112 this._userRequestInterceptionEnabled = value;
113 await this._updateProtocolRequestInterception();
114 }
115
116 async _updateProtocolRequestInterception() {
117 const enabled = this._userRequestInterceptionEnabled || !!this._credentials;
118 if (enabled === this._protocolRequestInterceptionEnabled)
119 return;
120 this._protocolRequestInterceptionEnabled = enabled;
121 const patterns = enabled ? [{urlPattern: '*'}] : [];
122 await Promise.all([
123 this._client.send('Network.setCacheDisabled', {cacheDisabled: enabled}),
124 this._client.send('Network.setRequestInterception', {patterns})
125 ]);
126 }
127
128 /**
129 * @param {!Protocol.Network.requestInterceptedPayload} event
130 */
131 _onRequestIntercepted(event) {
132 if (event.authChallenge) {
133 /** @type {"Default"|"CancelAuth"|"ProvideCredentials"} */
134 let response = 'Default';
135 if (this._attemptedAuthentications.has(event.interceptionId)) {
136 response = 'CancelAuth';
137 } else if (this._credentials) {
138 response = 'ProvideCredentials';
139 this._attemptedAuthentications.add(event.interceptionId);
140 }
141 const {username, password} = this._credentials || {username: undefined, password: undefined};
142 this._client.send('Network.continueInterceptedRequest', {
143 interceptionId: event.interceptionId,
144 authChallengeResponse: { response, username, password }
145 }).catch(debugError);
146 return;
147 }
148 if (!this._userRequestInterceptionEnabled && this._protocolRequestInterceptionEnabled) {
149 this._client.send('Network.continueInterceptedRequest', {
150 interceptionId: event.interceptionId
151 }).catch(debugError);
152 }
153
154 if (event.redirectUrl) {
155 const request = this._interceptionIdToRequest.get(event.interceptionId);
156 if (request) {
157 this._handleRequestRedirect(request, event.responseStatusCode, event.responseHeaders, false /* fromDiskCache */, false /* fromServiceWorker */, null /* securityDetails */);
158 this._handleRequestStart(request._requestId, event.interceptionId, event.redirectUrl, event.resourceType, event.request, event.frameId, request._redirectChain);
159 }
160 return;
161 }
162 const requestHash = generateRequestHash(event.request);
163 const requestId = this._requestHashToRequestIds.firstValue(requestHash);
164 if (requestId) {
165 this._requestHashToRequestIds.delete(requestHash, requestId);
166 this._handleRequestStart(requestId, event.interceptionId, event.request.url, event.resourceType, event.request, event.frameId, []);
167 } else {
168 this._requestHashToInterceptionIds.set(requestHash, event.interceptionId);
169 this._handleRequestStart(null, event.interceptionId, event.request.url, event.resourceType, event.request, event.frameId, []);
170 }
171 }
172
173 /**
174 * @param {!Protocol.Network.requestServedFromCachePayload} event
175 */
176 _onRequestServedFromCache(event) {
177 const request = this._requestIdToRequest.get(event.requestId);
178 if (request)
179 request._fromMemoryCache = true;
180 }
181
182 /**
183 * @param {!Request} request
184 * @param {number} redirectStatus
185 * @param {!Object} redirectHeaders
186 * @param {boolean} fromDiskCache
187 * @param {boolean} fromServiceWorker
188 * @param {?Object} securityDetails
189 */
190 _handleRequestRedirect(request, redirectStatus, redirectHeaders, fromDiskCache, fromServiceWorker, securityDetails) {
191 const response = new Response(this._client, request, redirectStatus, redirectHeaders, fromDiskCache, fromServiceWorker, securityDetails);
192 request._response = response;
193 request._redirectChain.push(request);
194 this._requestIdToRequest.delete(request._requestId);
195 this._interceptionIdToRequest.delete(request._interceptionId);
196 this._attemptedAuthentications.delete(request._interceptionId);
197 this.emit(NetworkManager.Events.Response, response);
198 this.emit(NetworkManager.Events.RequestFinished, request);
199 }
200
201 /**
202 * @param {?string} requestId
203 * @param {?string} interceptionId
204 * @param {string} url
205 * @param {string} resourceType
206 * @param {!Protocol.Network.Request} requestPayload
207 * @param {?string} frameId
208 * @param {!Array<!Request>} redirectChain
209 */
210 _handleRequestStart(requestId, interceptionId, url, resourceType, requestPayload, frameId, redirectChain) {
211 let frame = null;
212 if (frameId)
213 frame = this._frameManager.frame(frameId);
214 const request = new Request(this._client, requestId, interceptionId, this._userRequestInterceptionEnabled, url, resourceType, requestPayload, frame, redirectChain);
215 if (requestId)
216 this._requestIdToRequest.set(requestId, request);
217 if (interceptionId)
218 this._interceptionIdToRequest.set(interceptionId, request);
219 this.emit(NetworkManager.Events.Request, request);
220 }
221
222 /**
223 * @param {!Protocol.Network.requestWillBeSentPayload} event
224 */
225 _onRequestWillBeSent(event) {
226 if (this._protocolRequestInterceptionEnabled) {
227 // All redirects are handled in requestIntercepted.
228 if (event.redirectResponse)
229 return;
230 const requestHash = generateRequestHash(event.request);
231 const interceptionId = this._requestHashToInterceptionIds.firstValue(requestHash);
232 const request = interceptionId ? this._interceptionIdToRequest.get(interceptionId) : null;
233 if (request) {
234 request._requestId = event.requestId;
235 this._requestIdToRequest.set(event.requestId, request);
236 this._requestHashToInterceptionIds.delete(requestHash, interceptionId);
237 } else {
238 this._requestHashToRequestIds.set(requestHash, event.requestId);
239 }
240 return;
241 }
242 let redirectChain = [];
243 if (event.redirectResponse) {
244 const request = this._requestIdToRequest.get(event.requestId);
245 // If we connect late to the target, we could have missed the requestWillBeSent event.
246 if (request) {
247 this._handleRequestRedirect(request, event.redirectResponse.status, event.redirectResponse.headers, event.redirectResponse.fromDiskCache, event.redirectResponse.fromServiceWorker, event.redirectResponse.securityDetails);
248 redirectChain = request._redirectChain;
249 }
250 }
251 this._handleRequestStart(event.requestId, null, event.request.url, event.type, event.request, event.frameId, redirectChain);
252 }
253
254 /**
255 * @param {!Protocol.Network.responseReceivedPayload} event
256 */
257 _onResponseReceived(event) {
258 const request = this._requestIdToRequest.get(event.requestId);
259 // FileUpload sends a response without a matching request.
260 if (!request)
261 return;
262 const response = new Response(this._client, request, event.response.status, event.response.headers,
263 event.response.fromDiskCache, event.response.fromServiceWorker, event.response.securityDetails);
264 request._response = response;
265 this.emit(NetworkManager.Events.Response, response);
266 }
267
268 /**
269 * @param {!Protocol.Network.loadingFinishedPayload} event
270 */
271 _onLoadingFinished(event) {
272 const request = this._requestIdToRequest.get(event.requestId);
273 // For certain requestIds we never receive requestWillBeSent event.
274 // @see https://crbug.com/750469
275 if (!request)
276 return;
277 request._completePromiseFulfill.call(null);
278 this._requestIdToRequest.delete(request._requestId);
279 this._interceptionIdToRequest.delete(request._interceptionId);
280 this._attemptedAuthentications.delete(request._interceptionId);
281 this.emit(NetworkManager.Events.RequestFinished, request);
282 }
283
284 /**
285 * @param {!Protocol.Network.loadingFailedPayload} event
286 */
287 _onLoadingFailed(event) {
288 const request = this._requestIdToRequest.get(event.requestId);
289 // For certain requestIds we never receive requestWillBeSent event.
290 // @see https://crbug.com/750469
291 if (!request)
292 return;
293 request._failureText = event.errorText;
294 request._completePromiseFulfill.call(null);
295 this._requestIdToRequest.delete(request._requestId);
296 this._interceptionIdToRequest.delete(request._interceptionId);
297 this._attemptedAuthentications.delete(request._interceptionId);
298 this.emit(NetworkManager.Events.RequestFailed, request);
299 }
300}
301
302class Request {
303 /**
304 * @param {!Puppeteer.CDPSession} client
305 * @param {?string} requestId
306 * @param {string} interceptionId
307 * @param {boolean} allowInterception
308 * @param {string} url
309 * @param {string} resourceType
310 * @param {!Protocol.Network.Request} payload
311 * @param {?Puppeteer.Frame} frame
312 * @param {!Array<!Request>} redirectChain
313 */
314 constructor(client, requestId, interceptionId, allowInterception, url, resourceType, payload, frame, redirectChain) {
315 this._client = client;
316 this._requestId = requestId;
317 this._interceptionId = interceptionId;
318 this._allowInterception = allowInterception;
319 this._interceptionHandled = false;
320 this._response = null;
321 this._failureText = null;
322 this._completePromise = new Promise(fulfill => {
323 this._completePromiseFulfill = fulfill;
324 });
325
326 this._url = url;
327 this._resourceType = resourceType.toLowerCase();
328 this._method = payload.method;
329 this._postData = payload.postData;
330 this._headers = {};
331 this._frame = frame;
332 this._redirectChain = redirectChain;
333 for (const key of Object.keys(payload.headers))
334 this._headers[key.toLowerCase()] = payload.headers[key];
335
336 this._fromMemoryCache = false;
337 }
338
339 /**
340 * @return {string}
341 */
342 url() {
343 return this._url;
344 }
345
346 /**
347 * @return {string}
348 */
349 resourceType() {
350 return this._resourceType;
351 }
352
353 /**
354 * @return {string}
355 */
356 method() {
357 return this._method;
358 }
359
360 /**
361 * @return {string}
362 */
363 postData() {
364 return this._postData;
365 }
366
367 /**
368 * @return {!Object}
369 */
370 headers() {
371 return this._headers;
372 }
373
374 /**
375 * @return {?Response}
376 */
377 response() {
378 return this._response;
379 }
380
381 /**
382 * @return {?Puppeteer.Frame}
383 */
384 frame() {
385 return this._frame;
386 }
387
388 /**
389 * @return {!Array<!Request>}
390 */
391 redirectChain() {
392 return this._redirectChain.slice();
393 }
394
395 /**
396 * @return {?{errorText: string}}
397 */
398 failure() {
399 if (!this._failureText)
400 return null;
401 return {
402 errorText: this._failureText
403 };
404 }
405
406 /**
407 * @param {!Object=} overrides
408 */
409 async continue(overrides = {}) {
410 console.assert(this._allowInterception, 'Request Interception is not enabled!');
411 console.assert(!this._interceptionHandled, 'Request is already handled!');
412 this._interceptionHandled = true;
413 await this._client.send('Network.continueInterceptedRequest', {
414 interceptionId: this._interceptionId,
415 url: overrides.url,
416 method: overrides.method,
417 postData: overrides.postData,
418 headers: overrides.headers,
419 }).catch(error => {
420 // In certain cases, protocol will return error if the request was already canceled
421 // or the page was closed. We should tolerate these errors.
422 debugError(error);
423 });
424 }
425
426 /**
427 * @param {!{status: number, headers: Object, contentType: string, body: (string|Buffer)}} response
428 */
429 async respond(response) {
430 // Mocking responses for dataURL requests is not currently supported.
431 if (this._url.startsWith('data:'))
432 return;
433 console.assert(this._allowInterception, 'Request Interception is not enabled!');
434 console.assert(!this._interceptionHandled, 'Request is already handled!');
435 this._interceptionHandled = true;
436
437 const responseBody = response.body && helper.isString(response.body) ? Buffer.from(/** @type {string} */(response.body)) : /** @type {?Buffer} */(response.body || null);
438
439 const responseHeaders = {};
440 if (response.headers) {
441 for (const header of Object.keys(response.headers))
442 responseHeaders[header.toLowerCase()] = response.headers[header];
443 }
444 if (response.contentType)
445 responseHeaders['content-type'] = response.contentType;
446 if (responseBody && !('content-length' in responseHeaders)) {
447 // @ts-ignore
448 responseHeaders['content-length'] = Buffer.byteLength(responseBody);
449 }
450
451 const statusCode = response.status || 200;
452 const statusText = statusTexts[statusCode] || '';
453 const statusLine = `HTTP/1.1 ${statusCode} ${statusText}`;
454
455 const CRLF = '\r\n';
456 let text = statusLine + CRLF;
457 for (const header of Object.keys(responseHeaders))
458 text += header + ': ' + responseHeaders[header] + CRLF;
459 text += CRLF;
460 let responseBuffer = Buffer.from(text, 'utf8');
461 if (responseBody)
462 responseBuffer = Buffer.concat([responseBuffer, responseBody]);
463
464 await this._client.send('Network.continueInterceptedRequest', {
465 interceptionId: this._interceptionId,
466 rawResponse: responseBuffer.toString('base64')
467 }).catch(error => {
468 // In certain cases, protocol will return error if the request was already canceled
469 // or the page was closed. We should tolerate these errors.
470 debugError(error);
471 });
472 }
473
474 /**
475 * @param {string=} errorCode
476 */
477 async abort(errorCode = 'failed') {
478 const errorReason = errorReasons[errorCode];
479 console.assert(errorReason, 'Unknown error code: ' + errorCode);
480 console.assert(this._allowInterception, 'Request Interception is not enabled!');
481 console.assert(!this._interceptionHandled, 'Request is already handled!');
482 this._interceptionHandled = true;
483 await this._client.send('Network.continueInterceptedRequest', {
484 interceptionId: this._interceptionId,
485 errorReason
486 }).catch(error => {
487 // In certain cases, protocol will return error if the request was already canceled
488 // or the page was closed. We should tolerate these errors.
489 debugError(error);
490 });
491 }
492}
493
494const errorReasons = {
495 'aborted': 'Aborted',
496 'accessdenied': 'AccessDenied',
497 'addressunreachable': 'AddressUnreachable',
498 'connectionaborted': 'ConnectionAborted',
499 'connectionclosed': 'ConnectionClosed',
500 'connectionfailed': 'ConnectionFailed',
501 'connectionrefused': 'ConnectionRefused',
502 'connectionreset': 'ConnectionReset',
503 'internetdisconnected': 'InternetDisconnected',
504 'namenotresolved': 'NameNotResolved',
505 'timedout': 'TimedOut',
506 'failed': 'Failed',
507};
508
509helper.tracePublicAPI(Request);
510
511class Response {
512 /**
513 * @param {!Puppeteer.CDPSession} client
514 * @param {!Request} request
515 * @param {number} status
516 * @param {!Object} headers
517 * @param {boolean} fromDiskCache
518 * @param {boolean} fromServiceWorker
519 * @param {?Object} securityDetails
520 */
521 constructor(client, request, status, headers, fromDiskCache, fromServiceWorker, securityDetails) {
522 this._client = client;
523 this._request = request;
524 this._contentPromise = null;
525
526 this._status = status;
527 this._url = request.url();
528 this._fromDiskCache = fromDiskCache;
529 this._fromServiceWorker = fromServiceWorker;
530 this._headers = {};
531 for (const key of Object.keys(headers))
532 this._headers[key.toLowerCase()] = headers[key];
533 this._securityDetails = null;
534 if (securityDetails) {
535 this._securityDetails = new SecurityDetails(
536 securityDetails['subjectName'],
537 securityDetails['issuer'],
538 securityDetails['validFrom'],
539 securityDetails['validTo'],
540 securityDetails['protocol']);
541 }
542 }
543
544 /**
545 * @return {string}
546 */
547 url() {
548 return this._url;
549 }
550
551 /**
552 * @return {boolean}
553 */
554 ok() {
555 return this._status === 0 || (this._status >= 200 && this._status <= 299);
556 }
557
558 /**
559 * @return {number}
560 */
561 status() {
562 return this._status;
563 }
564
565 /**
566 * @return {!Object}
567 */
568 headers() {
569 return this._headers;
570 }
571
572 /**
573 * @return {?SecurityDetails}
574 */
575 securityDetails() {
576 return this._securityDetails;
577 }
578
579 /**
580 * @return {!Promise<!Buffer>}
581 */
582 buffer() {
583 if (!this._contentPromise) {
584 this._contentPromise = this._request._completePromise.then(async() => {
585 const response = await this._client.send('Network.getResponseBody', {
586 requestId: this._request._requestId
587 });
588 return Buffer.from(response.body, response.base64Encoded ? 'base64' : 'utf8');
589 });
590 }
591 return this._contentPromise;
592 }
593
594 /**
595 * @return {!Promise<string>}
596 */
597 async text() {
598 const content = await this.buffer();
599 return content.toString('utf8');
600 }
601
602 /**
603 * @return {!Promise<!Object>}
604 */
605 async json() {
606 const content = await this.text();
607 return JSON.parse(content);
608 }
609
610 /**
611 * @return {!Request}
612 */
613 request() {
614 return this._request;
615 }
616
617 /**
618 * @return {boolean}
619 */
620 fromCache() {
621 return this._fromDiskCache || this._request._fromMemoryCache;
622 }
623
624 /**
625 * @return {boolean}
626 */
627 fromServiceWorker() {
628 return this._fromServiceWorker;
629 }
630}
631helper.tracePublicAPI(Response);
632
633/**
634 * @param {!Protocol.Network.Request} request
635 * @return {string}
636 */
637function generateRequestHash(request) {
638 let normalizedURL = request.url;
639 try {
640 // Decoding is necessary to normalize URLs. @see crbug.com/759388
641 // The method will throw if the URL is malformed. In this case,
642 // consider URL to be normalized as-is.
643 normalizedURL = decodeURI(request.url);
644 } catch (e) {
645 }
646 const hash = {
647 url: normalizedURL,
648 method: request.method,
649 postData: request.postData,
650 headers: {},
651 };
652
653 if (!normalizedURL.startsWith('data:')) {
654 const headers = Object.keys(request.headers);
655 headers.sort();
656 for (let header of headers) {
657 const headerValue = request.headers[header];
658 header = header.toLowerCase();
659 if (header === 'accept' || header === 'referer' || header === 'x-devtools-emulate-network-conditions-client-id')
660 continue;
661 hash.headers[header] = headerValue;
662 }
663 }
664 return JSON.stringify(hash);
665}
666
667class SecurityDetails {
668 /**
669 * @param {string} subjectName
670 * @param {string} issuer
671 * @param {number} validFrom
672 * @param {number} validTo
673 * @param {string} protocol
674 */
675
676 constructor(subjectName, issuer, validFrom, validTo, protocol) {
677 this._subjectName = subjectName;
678 this._issuer = issuer;
679 this._validFrom = validFrom;
680 this._validTo = validTo;
681 this._protocol = protocol;
682 }
683
684 /**
685 * @return {string}
686 */
687 subjectName() {
688 return this._subjectName;
689 }
690
691 /**
692 * @return {string}
693 */
694 issuer() {
695 return this._issuer;
696 }
697
698 /**
699 * @return {number}
700 */
701 validFrom() {
702 return this._validFrom;
703 }
704
705 /**
706 * @return {number}
707 */
708 validTo() {
709 return this._validTo;
710 }
711
712 /**
713 * @return {string}
714 */
715 protocol() {
716 return this._protocol;
717 }
718}
719
720NetworkManager.Events = {
721 Request: 'request',
722 Response: 'response',
723 RequestFailed: 'requestfailed',
724 RequestFinished: 'requestfinished',
725};
726
727const statusTexts = {
728 '100': 'Continue',
729 '101': 'Switching Protocols',
730 '102': 'Processing',
731 '200': 'OK',
732 '201': 'Created',
733 '202': 'Accepted',
734 '203': 'Non-Authoritative Information',
735 '204': 'No Content',
736 '206': 'Partial Content',
737 '207': 'Multi-Status',
738 '208': 'Already Reported',
739 '209': 'IM Used',
740 '300': 'Multiple Choices',
741 '301': 'Moved Permanently',
742 '302': 'Found',
743 '303': 'See Other',
744 '304': 'Not Modified',
745 '305': 'Use Proxy',
746 '306': 'Switch Proxy',
747 '307': 'Temporary Redirect',
748 '308': 'Permanent Redirect',
749 '400': 'Bad Request',
750 '401': 'Unauthorized',
751 '402': 'Payment Required',
752 '403': 'Forbidden',
753 '404': 'Not Found',
754 '405': 'Method Not Allowed',
755 '406': 'Not Acceptable',
756 '407': 'Proxy Authentication Required',
757 '408': 'Request Timeout',
758 '409': 'Conflict',
759 '410': 'Gone',
760 '411': 'Length Required',
761 '412': 'Precondition Failed',
762 '413': 'Payload Too Large',
763 '414': 'URI Too Long',
764 '415': 'Unsupported Media Type',
765 '416': 'Range Not Satisfiable',
766 '417': 'Expectation Failed',
767 '418': 'I\'m a teapot',
768 '421': 'Misdirected Request',
769 '422': 'Unprocessable Entity',
770 '423': 'Locked',
771 '424': 'Failed Dependency',
772 '426': 'Upgrade Required',
773 '428': 'Precondition Required',
774 '429': 'Too Many Requests',
775 '431': 'Request Header Fields Too Large',
776 '451': 'Unavailable For Legal Reasons',
777 '500': 'Internal Server Error',
778 '501': 'Not Implemented',
779 '502': 'Bad Gateway',
780 '503': 'Service Unavailable',
781 '504': 'Gateway Timeout',
782 '505': 'HTTP Version Not Supported',
783 '506': 'Variant Also Negotiates',
784 '507': 'Insufficient Storage',
785 '508': 'Loop Detected',
786 '510': 'Not Extended',
787 '511': 'Network Authentication Required',
788};
789
790module.exports = {Request, Response, NetworkManager};