| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {WebInspector.ContentProvider} | 31 * @implements {Common.ContentProvider} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.NetworkRequest = class extends WebInspector.SDKObject { | 34 SDK.NetworkRequest = class extends SDK.SDKObject { |
| 35 /** | 35 /** |
| 36 * @param {!Protocol.Network.RequestId} requestId | 36 * @param {!Protocol.Network.RequestId} requestId |
| 37 * @param {!WebInspector.Target} target | 37 * @param {!SDK.Target} target |
| 38 * @param {string} url | 38 * @param {string} url |
| 39 * @param {string} documentURL | 39 * @param {string} documentURL |
| 40 * @param {!Protocol.Page.FrameId} frameId | 40 * @param {!Protocol.Page.FrameId} frameId |
| 41 * @param {!Protocol.Network.LoaderId} loaderId | 41 * @param {!Protocol.Network.LoaderId} loaderId |
| 42 * @param {?Protocol.Network.Initiator} initiator | 42 * @param {?Protocol.Network.Initiator} initiator |
| 43 */ | 43 */ |
| 44 constructor(target, requestId, url, documentURL, frameId, loaderId, initiator)
{ | 44 constructor(target, requestId, url, documentURL, frameId, loaderId, initiator)
{ |
| 45 super(target); | 45 super(target); |
| 46 | 46 |
| 47 this._networkLog = /** @type {!WebInspector.NetworkLog} */ (WebInspector.Net
workLog.fromTarget(target)); | 47 this._networkLog = /** @type {!SDK.NetworkLog} */ (SDK.NetworkLog.fromTarget
(target)); |
| 48 this._networkManager = /** @type {!WebInspector.NetworkManager} */ (WebInspe
ctor.NetworkManager.fromTarget(target)); | 48 this._networkManager = /** @type {!SDK.NetworkManager} */ (SDK.NetworkManage
r.fromTarget(target)); |
| 49 this._requestId = requestId; | 49 this._requestId = requestId; |
| 50 this.url = url; | 50 this.url = url; |
| 51 this._documentURL = documentURL; | 51 this._documentURL = documentURL; |
| 52 this._frameId = frameId; | 52 this._frameId = frameId; |
| 53 this._loaderId = loaderId; | 53 this._loaderId = loaderId; |
| 54 /** @type {?Protocol.Network.Initiator} */ | 54 /** @type {?Protocol.Network.Initiator} */ |
| 55 this._initiator = initiator; | 55 this._initiator = initiator; |
| 56 this._issueTime = -1; | 56 this._issueTime = -1; |
| 57 this._startTime = -1; | 57 this._startTime = -1; |
| 58 this._endTime = -1; | 58 this._endTime = -1; |
| 59 /** @type {!Protocol.Network.BlockedReason|undefined} */ | 59 /** @type {!Protocol.Network.BlockedReason|undefined} */ |
| 60 this._blockedReason = undefined; | 60 this._blockedReason = undefined; |
| 61 | 61 |
| 62 this.statusCode = 0; | 62 this.statusCode = 0; |
| 63 this.statusText = ''; | 63 this.statusText = ''; |
| 64 this.requestMethod = ''; | 64 this.requestMethod = ''; |
| 65 this.requestTime = 0; | 65 this.requestTime = 0; |
| 66 this.protocol = ''; | 66 this.protocol = ''; |
| 67 /** @type {!Protocol.Network.RequestMixedContentType} */ | 67 /** @type {!Protocol.Network.RequestMixedContentType} */ |
| 68 this.mixedContentType = Protocol.Network.RequestMixedContentType.None; | 68 this.mixedContentType = Protocol.Network.RequestMixedContentType.None; |
| 69 | 69 |
| 70 /** @type {?Protocol.Network.ResourcePriority} */ | 70 /** @type {?Protocol.Network.ResourcePriority} */ |
| 71 this._initialPriority = null; | 71 this._initialPriority = null; |
| 72 /** @type {?Protocol.Network.ResourcePriority} */ | 72 /** @type {?Protocol.Network.ResourcePriority} */ |
| 73 this._currentPriority = null; | 73 this._currentPriority = null; |
| 74 | 74 |
| 75 /** @type {!WebInspector.ResourceType} */ | 75 /** @type {!Common.ResourceType} */ |
| 76 this._resourceType = WebInspector.resourceTypes.Other; | 76 this._resourceType = Common.resourceTypes.Other; |
| 77 this._contentEncoded = false; | 77 this._contentEncoded = false; |
| 78 this._pendingContentCallbacks = []; | 78 this._pendingContentCallbacks = []; |
| 79 /** @type {!Array.<!WebInspector.NetworkRequest.WebSocketFrame>} */ | 79 /** @type {!Array.<!SDK.NetworkRequest.WebSocketFrame>} */ |
| 80 this._frames = []; | 80 this._frames = []; |
| 81 /** @type {!Array.<!WebInspector.NetworkRequest.EventSourceMessage>} */ | 81 /** @type {!Array.<!SDK.NetworkRequest.EventSourceMessage>} */ |
| 82 this._eventSourceMessages = []; | 82 this._eventSourceMessages = []; |
| 83 | 83 |
| 84 this._responseHeaderValues = {}; | 84 this._responseHeaderValues = {}; |
| 85 | 85 |
| 86 this._remoteAddress = ''; | 86 this._remoteAddress = ''; |
| 87 | 87 |
| 88 /** @type {!Protocol.Security.SecurityState} */ | 88 /** @type {!Protocol.Security.SecurityState} */ |
| 89 this._securityState = Protocol.Security.SecurityState.Unknown; | 89 this._securityState = Protocol.Security.SecurityState.Unknown; |
| 90 /** @type {?Protocol.Network.SecurityDetails} */ | 90 /** @type {?Protocol.Network.SecurityDetails} */ |
| 91 this._securityDetails = null; | 91 this._securityDetails = null; |
| 92 | 92 |
| 93 /** @type {string} */ | 93 /** @type {string} */ |
| 94 this.connectionId = '0'; | 94 this.connectionId = '0'; |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * @param {!WebInspector.NetworkRequest} other | 98 * @param {!SDK.NetworkRequest} other |
| 99 * @return {number} | 99 * @return {number} |
| 100 */ | 100 */ |
| 101 indentityCompare(other) { | 101 indentityCompare(other) { |
| 102 if (this._requestId > other._requestId) | 102 if (this._requestId > other._requestId) |
| 103 return 1; | 103 return 1; |
| 104 if (this._requestId < other._requestId) | 104 if (this._requestId < other._requestId) |
| 105 return -1; | 105 return -1; |
| 106 return 0; | 106 return 0; |
| 107 } | 107 } |
| 108 | 108 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * @param {string} x | 131 * @param {string} x |
| 132 */ | 132 */ |
| 133 set url(x) { | 133 set url(x) { |
| 134 if (this._url === x) | 134 if (this._url === x) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 this._url = x; | 137 this._url = x; |
| 138 this._parsedURL = new WebInspector.ParsedURL(x); | 138 this._parsedURL = new Common.ParsedURL(x); |
| 139 delete this._queryString; | 139 delete this._queryString; |
| 140 delete this._parsedQueryParameters; | 140 delete this._parsedQueryParameters; |
| 141 delete this._name; | 141 delete this._name; |
| 142 delete this._path; | 142 delete this._path; |
| 143 } | 143 } |
| 144 | 144 |
| 145 /** | 145 /** |
| 146 * @return {string} | 146 * @return {string} |
| 147 */ | 147 */ |
| 148 get documentURL() { | 148 get documentURL() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 166 get loaderId() { | 166 get loaderId() { |
| 167 return this._loaderId; | 167 return this._loaderId; |
| 168 } | 168 } |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * @param {string} ip | 171 * @param {string} ip |
| 172 * @param {number} port | 172 * @param {number} port |
| 173 */ | 173 */ |
| 174 setRemoteAddress(ip, port) { | 174 setRemoteAddress(ip, port) { |
| 175 this._remoteAddress = ip + ':' + port; | 175 this._remoteAddress = ip + ':' + port; |
| 176 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.RemoteAddre
ssChanged, this); | 176 this.dispatchEventToListeners(SDK.NetworkRequest.Events.RemoteAddressChanged
, this); |
| 177 } | 177 } |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * @return {string} | 180 * @return {string} |
| 181 */ | 181 */ |
| 182 remoteAddress() { | 182 remoteAddress() { |
| 183 return this._remoteAddress; | 183 return this._remoteAddress; |
| 184 } | 184 } |
| 185 | 185 |
| 186 /** | 186 /** |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 set endTime(x) { | 270 set endTime(x) { |
| 271 if (this.timing && this.timing.requestTime) { | 271 if (this.timing && this.timing.requestTime) { |
| 272 // Check against accurate responseReceivedTime. | 272 // Check against accurate responseReceivedTime. |
| 273 this._endTime = Math.max(x, this.responseReceivedTime); | 273 this._endTime = Math.max(x, this.responseReceivedTime); |
| 274 } else { | 274 } else { |
| 275 // Prefer endTime since it might be from the network stack. | 275 // Prefer endTime since it might be from the network stack. |
| 276 this._endTime = x; | 276 this._endTime = x; |
| 277 if (this._responseReceivedTime > x) | 277 if (this._responseReceivedTime > x) |
| 278 this._responseReceivedTime = x; | 278 this._responseReceivedTime = x; |
| 279 } | 279 } |
| 280 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.TimingChang
ed, this); | 280 this.dispatchEventToListeners(SDK.NetworkRequest.Events.TimingChanged, this)
; |
| 281 } | 281 } |
| 282 | 282 |
| 283 /** | 283 /** |
| 284 * @return {number} | 284 * @return {number} |
| 285 */ | 285 */ |
| 286 get duration() { | 286 get duration() { |
| 287 if (this._endTime === -1 || this._startTime === -1) | 287 if (this._endTime === -1 || this._startTime === -1) |
| 288 return -1; | 288 return -1; |
| 289 return this._endTime - this._startTime; | 289 return this._endTime - this._startTime; |
| 290 } | 290 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 /** | 343 /** |
| 344 * @param {boolean} x | 344 * @param {boolean} x |
| 345 */ | 345 */ |
| 346 set finished(x) { | 346 set finished(x) { |
| 347 if (this._finished === x) | 347 if (this._finished === x) |
| 348 return; | 348 return; |
| 349 | 349 |
| 350 this._finished = x; | 350 this._finished = x; |
| 351 | 351 |
| 352 if (x) { | 352 if (x) { |
| 353 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.FinishedL
oading, this); | 353 this.dispatchEventToListeners(SDK.NetworkRequest.Events.FinishedLoading, t
his); |
| 354 if (this._pendingContentCallbacks.length) | 354 if (this._pendingContentCallbacks.length) |
| 355 this._innerRequestContent(); | 355 this._innerRequestContent(); |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 | 358 |
| 359 /** | 359 /** |
| 360 * @return {boolean} | 360 * @return {boolean} |
| 361 */ | 361 */ |
| 362 get failed() { | 362 get failed() { |
| 363 return this._failed; | 363 return this._failed; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 * @param {!Protocol.Network.ResourceTiming|undefined} x | 453 * @param {!Protocol.Network.ResourceTiming|undefined} x |
| 454 */ | 454 */ |
| 455 set timing(x) { | 455 set timing(x) { |
| 456 if (x && !this._fromMemoryCache) { | 456 if (x && !this._fromMemoryCache) { |
| 457 // Take startTime and responseReceivedTime from timing data for better acc
uracy. | 457 // Take startTime and responseReceivedTime from timing data for better acc
uracy. |
| 458 // Timing's requestTime is a baseline in seconds, rest of the numbers ther
e are ticks in millis. | 458 // Timing's requestTime is a baseline in seconds, rest of the numbers ther
e are ticks in millis. |
| 459 this._startTime = x.requestTime; | 459 this._startTime = x.requestTime; |
| 460 this._responseReceivedTime = x.requestTime + x.receiveHeadersEnd / 1000.0; | 460 this._responseReceivedTime = x.requestTime + x.receiveHeadersEnd / 1000.0; |
| 461 | 461 |
| 462 this._timing = x; | 462 this._timing = x; |
| 463 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.TimingCha
nged, this); | 463 this.dispatchEventToListeners(SDK.NetworkRequest.Events.TimingChanged, thi
s); |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 | 466 |
| 467 /** | 467 /** |
| 468 * @return {string} | 468 * @return {string} |
| 469 */ | 469 */ |
| 470 get mimeType() { | 470 get mimeType() { |
| 471 return this._mimeType; | 471 return this._mimeType; |
| 472 } | 472 } |
| 473 | 473 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 get folder() { | 538 get folder() { |
| 539 var path = this._parsedURL.path; | 539 var path = this._parsedURL.path; |
| 540 var indexOfQuery = path.indexOf('?'); | 540 var indexOfQuery = path.indexOf('?'); |
| 541 if (indexOfQuery !== -1) | 541 if (indexOfQuery !== -1) |
| 542 path = path.substring(0, indexOfQuery); | 542 path = path.substring(0, indexOfQuery); |
| 543 var lastSlashIndex = path.lastIndexOf('/'); | 543 var lastSlashIndex = path.lastIndexOf('/'); |
| 544 return lastSlashIndex !== -1 ? path.substring(0, lastSlashIndex) : ''; | 544 return lastSlashIndex !== -1 ? path.substring(0, lastSlashIndex) : ''; |
| 545 } | 545 } |
| 546 | 546 |
| 547 /** | 547 /** |
| 548 * @return {!WebInspector.ResourceType} | 548 * @return {!Common.ResourceType} |
| 549 */ | 549 */ |
| 550 resourceType() { | 550 resourceType() { |
| 551 return this._resourceType; | 551 return this._resourceType; |
| 552 } | 552 } |
| 553 | 553 |
| 554 /** | 554 /** |
| 555 * @param {!WebInspector.ResourceType} resourceType | 555 * @param {!Common.ResourceType} resourceType |
| 556 */ | 556 */ |
| 557 setResourceType(resourceType) { | 557 setResourceType(resourceType) { |
| 558 this._resourceType = resourceType; | 558 this._resourceType = resourceType; |
| 559 } | 559 } |
| 560 | 560 |
| 561 /** | 561 /** |
| 562 * @return {string} | 562 * @return {string} |
| 563 */ | 563 */ |
| 564 get domain() { | 564 get domain() { |
| 565 return this._parsedURL.host; | 565 return this._parsedURL.host; |
| 566 } | 566 } |
| 567 | 567 |
| 568 /** | 568 /** |
| 569 * @return {string} | 569 * @return {string} |
| 570 */ | 570 */ |
| 571 get scheme() { | 571 get scheme() { |
| 572 return this._parsedURL.scheme; | 572 return this._parsedURL.scheme; |
| 573 } | 573 } |
| 574 | 574 |
| 575 /** | 575 /** |
| 576 * @return {?WebInspector.NetworkRequest} | 576 * @return {?SDK.NetworkRequest} |
| 577 */ | 577 */ |
| 578 get redirectSource() { | 578 get redirectSource() { |
| 579 if (this.redirects && this.redirects.length > 0) | 579 if (this.redirects && this.redirects.length > 0) |
| 580 return this.redirects[this.redirects.length - 1]; | 580 return this.redirects[this.redirects.length - 1]; |
| 581 return this._redirectSource; | 581 return this._redirectSource; |
| 582 } | 582 } |
| 583 | 583 |
| 584 /** | 584 /** |
| 585 * @param {?WebInspector.NetworkRequest} x | 585 * @param {?SDK.NetworkRequest} x |
| 586 */ | 586 */ |
| 587 set redirectSource(x) { | 587 set redirectSource(x) { |
| 588 this._redirectSource = x; | 588 this._redirectSource = x; |
| 589 delete this._initiatorInfo; | 589 delete this._initiatorInfo; |
| 590 } | 590 } |
| 591 | 591 |
| 592 /** | 592 /** |
| 593 * @return {!Array.<!WebInspector.NetworkRequest.NameValue>} | 593 * @return {!Array.<!SDK.NetworkRequest.NameValue>} |
| 594 */ | 594 */ |
| 595 requestHeaders() { | 595 requestHeaders() { |
| 596 return this._requestHeaders || []; | 596 return this._requestHeaders || []; |
| 597 } | 597 } |
| 598 | 598 |
| 599 /** | 599 /** |
| 600 * @param {!Array.<!WebInspector.NetworkRequest.NameValue>} headers | 600 * @param {!Array.<!SDK.NetworkRequest.NameValue>} headers |
| 601 */ | 601 */ |
| 602 setRequestHeaders(headers) { | 602 setRequestHeaders(headers) { |
| 603 this._requestHeaders = headers; | 603 this._requestHeaders = headers; |
| 604 delete this._requestCookies; | 604 delete this._requestCookies; |
| 605 | 605 |
| 606 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.RequestHead
ersChanged); | 606 this.dispatchEventToListeners(SDK.NetworkRequest.Events.RequestHeadersChange
d); |
| 607 } | 607 } |
| 608 | 608 |
| 609 /** | 609 /** |
| 610 * @return {string|undefined} | 610 * @return {string|undefined} |
| 611 */ | 611 */ |
| 612 requestHeadersText() { | 612 requestHeadersText() { |
| 613 return this._requestHeadersText; | 613 return this._requestHeadersText; |
| 614 } | 614 } |
| 615 | 615 |
| 616 /** | 616 /** |
| 617 * @param {string} text | 617 * @param {string} text |
| 618 */ | 618 */ |
| 619 setRequestHeadersText(text) { | 619 setRequestHeadersText(text) { |
| 620 this._requestHeadersText = text; | 620 this._requestHeadersText = text; |
| 621 | 621 |
| 622 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.RequestHead
ersChanged); | 622 this.dispatchEventToListeners(SDK.NetworkRequest.Events.RequestHeadersChange
d); |
| 623 } | 623 } |
| 624 | 624 |
| 625 /** | 625 /** |
| 626 * @param {string} headerName | 626 * @param {string} headerName |
| 627 * @return {string|undefined} | 627 * @return {string|undefined} |
| 628 */ | 628 */ |
| 629 requestHeaderValue(headerName) { | 629 requestHeaderValue(headerName) { |
| 630 return this._headerValue(this.requestHeaders(), headerName); | 630 return this._headerValue(this.requestHeaders(), headerName); |
| 631 } | 631 } |
| 632 | 632 |
| 633 /** | 633 /** |
| 634 * @return {!Array.<!WebInspector.Cookie>} | 634 * @return {!Array.<!SDK.Cookie>} |
| 635 */ | 635 */ |
| 636 get requestCookies() { | 636 get requestCookies() { |
| 637 if (!this._requestCookies) | 637 if (!this._requestCookies) |
| 638 this._requestCookies = WebInspector.CookieParser.parseCookie(this.target()
, this.requestHeaderValue('Cookie')); | 638 this._requestCookies = SDK.CookieParser.parseCookie(this.target(), this.re
questHeaderValue('Cookie')); |
| 639 return this._requestCookies; | 639 return this._requestCookies; |
| 640 } | 640 } |
| 641 | 641 |
| 642 /** | 642 /** |
| 643 * @return {string|undefined} | 643 * @return {string|undefined} |
| 644 */ | 644 */ |
| 645 get requestFormData() { | 645 get requestFormData() { |
| 646 return this._requestFormData; | 646 return this._requestFormData; |
| 647 } | 647 } |
| 648 | 648 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 660 requestHttpVersion() { | 660 requestHttpVersion() { |
| 661 var headersText = this.requestHeadersText(); | 661 var headersText = this.requestHeadersText(); |
| 662 if (!headersText) | 662 if (!headersText) |
| 663 return this.requestHeaderValue('version') || this.requestHeaderValue(':ver
sion') || 'unknown'; | 663 return this.requestHeaderValue('version') || this.requestHeaderValue(':ver
sion') || 'unknown'; |
| 664 var firstLine = headersText.split(/\r\n/)[0]; | 664 var firstLine = headersText.split(/\r\n/)[0]; |
| 665 var match = firstLine.match(/(HTTP\/\d+\.\d+)$/); | 665 var match = firstLine.match(/(HTTP\/\d+\.\d+)$/); |
| 666 return match ? match[1] : 'HTTP/0.9'; | 666 return match ? match[1] : 'HTTP/0.9'; |
| 667 } | 667 } |
| 668 | 668 |
| 669 /** | 669 /** |
| 670 * @return {!Array.<!WebInspector.NetworkRequest.NameValue>} | 670 * @return {!Array.<!SDK.NetworkRequest.NameValue>} |
| 671 */ | 671 */ |
| 672 get responseHeaders() { | 672 get responseHeaders() { |
| 673 return this._responseHeaders || []; | 673 return this._responseHeaders || []; |
| 674 } | 674 } |
| 675 | 675 |
| 676 /** | 676 /** |
| 677 * @param {!Array.<!WebInspector.NetworkRequest.NameValue>} x | 677 * @param {!Array.<!SDK.NetworkRequest.NameValue>} x |
| 678 */ | 678 */ |
| 679 set responseHeaders(x) { | 679 set responseHeaders(x) { |
| 680 this._responseHeaders = x; | 680 this._responseHeaders = x; |
| 681 delete this._sortedResponseHeaders; | 681 delete this._sortedResponseHeaders; |
| 682 delete this._serverTimings; | 682 delete this._serverTimings; |
| 683 delete this._responseCookies; | 683 delete this._responseCookies; |
| 684 this._responseHeaderValues = {}; | 684 this._responseHeaderValues = {}; |
| 685 | 685 |
| 686 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.ResponseHea
dersChanged); | 686 this.dispatchEventToListeners(SDK.NetworkRequest.Events.ResponseHeadersChang
ed); |
| 687 } | 687 } |
| 688 | 688 |
| 689 /** | 689 /** |
| 690 * @return {string} | 690 * @return {string} |
| 691 */ | 691 */ |
| 692 get responseHeadersText() { | 692 get responseHeadersText() { |
| 693 return this._responseHeadersText; | 693 return this._responseHeadersText; |
| 694 } | 694 } |
| 695 | 695 |
| 696 /** | 696 /** |
| 697 * @param {string} x | 697 * @param {string} x |
| 698 */ | 698 */ |
| 699 set responseHeadersText(x) { | 699 set responseHeadersText(x) { |
| 700 this._responseHeadersText = x; | 700 this._responseHeadersText = x; |
| 701 | 701 |
| 702 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.ResponseHea
dersChanged); | 702 this.dispatchEventToListeners(SDK.NetworkRequest.Events.ResponseHeadersChang
ed); |
| 703 } | 703 } |
| 704 | 704 |
| 705 /** | 705 /** |
| 706 * @return {!Array.<!WebInspector.NetworkRequest.NameValue>} | 706 * @return {!Array.<!SDK.NetworkRequest.NameValue>} |
| 707 */ | 707 */ |
| 708 get sortedResponseHeaders() { | 708 get sortedResponseHeaders() { |
| 709 if (this._sortedResponseHeaders !== undefined) | 709 if (this._sortedResponseHeaders !== undefined) |
| 710 return this._sortedResponseHeaders; | 710 return this._sortedResponseHeaders; |
| 711 | 711 |
| 712 this._sortedResponseHeaders = this.responseHeaders.slice(); | 712 this._sortedResponseHeaders = this.responseHeaders.slice(); |
| 713 this._sortedResponseHeaders.sort(function(a, b) { | 713 this._sortedResponseHeaders.sort(function(a, b) { |
| 714 return a.name.toLowerCase().compareTo(b.name.toLowerCase()); | 714 return a.name.toLowerCase().compareTo(b.name.toLowerCase()); |
| 715 }); | 715 }); |
| 716 return this._sortedResponseHeaders; | 716 return this._sortedResponseHeaders; |
| 717 } | 717 } |
| 718 | 718 |
| 719 /** | 719 /** |
| 720 * @param {string} headerName | 720 * @param {string} headerName |
| 721 * @return {string|undefined} | 721 * @return {string|undefined} |
| 722 */ | 722 */ |
| 723 responseHeaderValue(headerName) { | 723 responseHeaderValue(headerName) { |
| 724 var value = this._responseHeaderValues[headerName]; | 724 var value = this._responseHeaderValues[headerName]; |
| 725 if (value === undefined) { | 725 if (value === undefined) { |
| 726 value = this._headerValue(this.responseHeaders, headerName); | 726 value = this._headerValue(this.responseHeaders, headerName); |
| 727 this._responseHeaderValues[headerName] = (value !== undefined) ? value : n
ull; | 727 this._responseHeaderValues[headerName] = (value !== undefined) ? value : n
ull; |
| 728 } | 728 } |
| 729 return (value !== null) ? value : undefined; | 729 return (value !== null) ? value : undefined; |
| 730 } | 730 } |
| 731 | 731 |
| 732 /** | 732 /** |
| 733 * @return {!Array.<!WebInspector.Cookie>} | 733 * @return {!Array.<!SDK.Cookie>} |
| 734 */ | 734 */ |
| 735 get responseCookies() { | 735 get responseCookies() { |
| 736 if (!this._responseCookies) | 736 if (!this._responseCookies) |
| 737 this._responseCookies = | 737 this._responseCookies = |
| 738 WebInspector.CookieParser.parseSetCookie(this.target(), this.responseH
eaderValue('Set-Cookie')); | 738 SDK.CookieParser.parseSetCookie(this.target(), this.responseHeaderValu
e('Set-Cookie')); |
| 739 return this._responseCookies; | 739 return this._responseCookies; |
| 740 } | 740 } |
| 741 | 741 |
| 742 /** | 742 /** |
| 743 * @return {string|undefined} | 743 * @return {string|undefined} |
| 744 */ | 744 */ |
| 745 responseLastModified() { | 745 responseLastModified() { |
| 746 return this.responseHeaderValue('last-modified'); | 746 return this.responseHeaderValue('last-modified'); |
| 747 } | 747 } |
| 748 | 748 |
| 749 /** | 749 /** |
| 750 * @return {?Array.<!WebInspector.ServerTiming>} | 750 * @return {?Array.<!SDK.ServerTiming>} |
| 751 */ | 751 */ |
| 752 get serverTimings() { | 752 get serverTimings() { |
| 753 if (typeof this._serverTimings === 'undefined') | 753 if (typeof this._serverTimings === 'undefined') |
| 754 this._serverTimings = WebInspector.ServerTiming.parseHeaders(this.response
Headers); | 754 this._serverTimings = SDK.ServerTiming.parseHeaders(this.responseHeaders); |
| 755 return this._serverTimings; | 755 return this._serverTimings; |
| 756 } | 756 } |
| 757 | 757 |
| 758 /** | 758 /** |
| 759 * @return {?string} | 759 * @return {?string} |
| 760 */ | 760 */ |
| 761 queryString() { | 761 queryString() { |
| 762 if (this._queryString !== undefined) | 762 if (this._queryString !== undefined) |
| 763 return this._queryString; | 763 return this._queryString; |
| 764 | 764 |
| 765 var queryString = null; | 765 var queryString = null; |
| 766 var url = this.url; | 766 var url = this.url; |
| 767 var questionMarkPosition = url.indexOf('?'); | 767 var questionMarkPosition = url.indexOf('?'); |
| 768 if (questionMarkPosition !== -1) { | 768 if (questionMarkPosition !== -1) { |
| 769 queryString = url.substring(questionMarkPosition + 1); | 769 queryString = url.substring(questionMarkPosition + 1); |
| 770 var hashSignPosition = queryString.indexOf('#'); | 770 var hashSignPosition = queryString.indexOf('#'); |
| 771 if (hashSignPosition !== -1) | 771 if (hashSignPosition !== -1) |
| 772 queryString = queryString.substring(0, hashSignPosition); | 772 queryString = queryString.substring(0, hashSignPosition); |
| 773 } | 773 } |
| 774 this._queryString = queryString; | 774 this._queryString = queryString; |
| 775 return this._queryString; | 775 return this._queryString; |
| 776 } | 776 } |
| 777 | 777 |
| 778 /** | 778 /** |
| 779 * @return {?Array.<!WebInspector.NetworkRequest.NameValue>} | 779 * @return {?Array.<!SDK.NetworkRequest.NameValue>} |
| 780 */ | 780 */ |
| 781 get queryParameters() { | 781 get queryParameters() { |
| 782 if (this._parsedQueryParameters) | 782 if (this._parsedQueryParameters) |
| 783 return this._parsedQueryParameters; | 783 return this._parsedQueryParameters; |
| 784 var queryString = this.queryString(); | 784 var queryString = this.queryString(); |
| 785 if (!queryString) | 785 if (!queryString) |
| 786 return null; | 786 return null; |
| 787 this._parsedQueryParameters = this._parseParameters(queryString); | 787 this._parsedQueryParameters = this._parseParameters(queryString); |
| 788 return this._parsedQueryParameters; | 788 return this._parsedQueryParameters; |
| 789 } | 789 } |
| 790 | 790 |
| 791 /** | 791 /** |
| 792 * @return {?Array.<!WebInspector.NetworkRequest.NameValue>} | 792 * @return {?Array.<!SDK.NetworkRequest.NameValue>} |
| 793 */ | 793 */ |
| 794 get formParameters() { | 794 get formParameters() { |
| 795 if (this._parsedFormParameters) | 795 if (this._parsedFormParameters) |
| 796 return this._parsedFormParameters; | 796 return this._parsedFormParameters; |
| 797 if (!this.requestFormData) | 797 if (!this.requestFormData) |
| 798 return null; | 798 return null; |
| 799 var requestContentType = this.requestContentType(); | 799 var requestContentType = this.requestContentType(); |
| 800 if (!requestContentType || !requestContentType.match(/^application\/x-www-fo
rm-urlencoded\s*(;.*)?$/i)) | 800 if (!requestContentType || !requestContentType.match(/^application\/x-www-fo
rm-urlencoded\s*(;.*)?$/i)) |
| 801 return null; | 801 return null; |
| 802 this._parsedFormParameters = this._parseParameters(this.requestFormData); | 802 this._parsedFormParameters = this._parseParameters(this.requestFormData); |
| 803 return this._parsedFormParameters; | 803 return this._parsedFormParameters; |
| 804 } | 804 } |
| 805 | 805 |
| 806 /** | 806 /** |
| 807 * @return {string} | 807 * @return {string} |
| 808 */ | 808 */ |
| 809 responseHttpVersion() { | 809 responseHttpVersion() { |
| 810 var headersText = this._responseHeadersText; | 810 var headersText = this._responseHeadersText; |
| 811 if (!headersText) | 811 if (!headersText) |
| 812 return this.responseHeaderValue('version') || this.responseHeaderValue(':v
ersion') || 'unknown'; | 812 return this.responseHeaderValue('version') || this.responseHeaderValue(':v
ersion') || 'unknown'; |
| 813 var firstLine = headersText.split(/\r\n/)[0]; | 813 var firstLine = headersText.split(/\r\n/)[0]; |
| 814 var match = firstLine.match(/^(HTTP\/\d+\.\d+)/); | 814 var match = firstLine.match(/^(HTTP\/\d+\.\d+)/); |
| 815 return match ? match[1] : 'HTTP/0.9'; | 815 return match ? match[1] : 'HTTP/0.9'; |
| 816 } | 816 } |
| 817 | 817 |
| 818 /** | 818 /** |
| 819 * @param {string} queryString | 819 * @param {string} queryString |
| 820 * @return {!Array.<!WebInspector.NetworkRequest.NameValue>} | 820 * @return {!Array.<!SDK.NetworkRequest.NameValue>} |
| 821 */ | 821 */ |
| 822 _parseParameters(queryString) { | 822 _parseParameters(queryString) { |
| 823 function parseNameValue(pair) { | 823 function parseNameValue(pair) { |
| 824 var position = pair.indexOf('='); | 824 var position = pair.indexOf('='); |
| 825 if (position === -1) | 825 if (position === -1) |
| 826 return {name: pair, value: ''}; | 826 return {name: pair, value: ''}; |
| 827 else | 827 else |
| 828 return {name: pair.substring(0, position), value: pair.substring(positio
n + 1)}; | 828 return {name: pair.substring(0, position), value: pair.substring(positio
n + 1)}; |
| 829 } | 829 } |
| 830 return queryString.split('&').map(parseNameValue); | 830 return queryString.split('&').map(parseNameValue); |
| 831 } | 831 } |
| 832 | 832 |
| 833 /** | 833 /** |
| 834 * @param {!Array.<!WebInspector.NetworkRequest.NameValue>} headers | 834 * @param {!Array.<!SDK.NetworkRequest.NameValue>} headers |
| 835 * @param {string} headerName | 835 * @param {string} headerName |
| 836 * @return {string|undefined} | 836 * @return {string|undefined} |
| 837 */ | 837 */ |
| 838 _headerValue(headers, headerName) { | 838 _headerValue(headers, headerName) { |
| 839 headerName = headerName.toLowerCase(); | 839 headerName = headerName.toLowerCase(); |
| 840 | 840 |
| 841 var values = []; | 841 var values = []; |
| 842 for (var i = 0; i < headers.length; ++i) { | 842 for (var i = 0; i < headers.length; ++i) { |
| 843 if (headers[i].name.toLowerCase() === headerName) | 843 if (headers[i].name.toLowerCase() === headerName) |
| 844 values.push(headers[i].value); | 844 values.push(headers[i].value); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 875 /** | 875 /** |
| 876 * @override | 876 * @override |
| 877 * @return {string} | 877 * @return {string} |
| 878 */ | 878 */ |
| 879 contentURL() { | 879 contentURL() { |
| 880 return this._url; | 880 return this._url; |
| 881 } | 881 } |
| 882 | 882 |
| 883 /** | 883 /** |
| 884 * @override | 884 * @override |
| 885 * @return {!WebInspector.ResourceType} | 885 * @return {!Common.ResourceType} |
| 886 */ | 886 */ |
| 887 contentType() { | 887 contentType() { |
| 888 return this._resourceType; | 888 return this._resourceType; |
| 889 } | 889 } |
| 890 | 890 |
| 891 /** | 891 /** |
| 892 * @override | 892 * @override |
| 893 * @return {!Promise<?string>} | 893 * @return {!Promise<?string>} |
| 894 */ | 894 */ |
| 895 requestContent() { | 895 requestContent() { |
| 896 // We do not support content retrieval for WebSockets at the moment. | 896 // We do not support content retrieval for WebSockets at the moment. |
| 897 // Since WebSockets are potentially long-living, fail requests immediately | 897 // Since WebSockets are potentially long-living, fail requests immediately |
| 898 // to prevent caller blocking until resource is marked as finished. | 898 // to prevent caller blocking until resource is marked as finished. |
| 899 if (this._resourceType === WebInspector.resourceTypes.WebSocket) | 899 if (this._resourceType === Common.resourceTypes.WebSocket) |
| 900 return Promise.resolve(/** @type {?string} */ (null)); | 900 return Promise.resolve(/** @type {?string} */ (null)); |
| 901 if (typeof this._content !== 'undefined') | 901 if (typeof this._content !== 'undefined') |
| 902 return Promise.resolve(/** @type {?string} */ (this.content || null)); | 902 return Promise.resolve(/** @type {?string} */ (this.content || null)); |
| 903 var callback; | 903 var callback; |
| 904 var promise = new Promise(fulfill => callback = fulfill); | 904 var promise = new Promise(fulfill => callback = fulfill); |
| 905 this._pendingContentCallbacks.push(callback); | 905 this._pendingContentCallbacks.push(callback); |
| 906 if (this.finished) | 906 if (this.finished) |
| 907 this._innerRequestContent(); | 907 this._innerRequestContent(); |
| 908 return promise; | 908 return promise; |
| 909 } | 909 } |
| 910 | 910 |
| 911 /** | 911 /** |
| 912 * @override | 912 * @override |
| 913 * @param {string} query | 913 * @param {string} query |
| 914 * @param {boolean} caseSensitive | 914 * @param {boolean} caseSensitive |
| 915 * @param {boolean} isRegex | 915 * @param {boolean} isRegex |
| 916 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callb
ack | 916 * @param {function(!Array.<!Common.ContentProvider.SearchMatch>)} callback |
| 917 */ | 917 */ |
| 918 searchInContent(query, caseSensitive, isRegex, callback) { | 918 searchInContent(query, caseSensitive, isRegex, callback) { |
| 919 callback([]); | 919 callback([]); |
| 920 } | 920 } |
| 921 | 921 |
| 922 /** | 922 /** |
| 923 * @return {boolean} | 923 * @return {boolean} |
| 924 */ | 924 */ |
| 925 isHttpFamily() { | 925 isHttpFamily() { |
| 926 return !!this.url.match(/^https?:/i); | 926 return !!this.url.match(/^https?:/i); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 priority() { | 967 priority() { |
| 968 return this._currentPriority || this._initialPriority || null; | 968 return this._currentPriority || this._initialPriority || null; |
| 969 } | 969 } |
| 970 | 970 |
| 971 /** | 971 /** |
| 972 * @param {!Element} image | 972 * @param {!Element} image |
| 973 */ | 973 */ |
| 974 populateImageSource(image) { | 974 populateImageSource(image) { |
| 975 /** | 975 /** |
| 976 * @param {?string} content | 976 * @param {?string} content |
| 977 * @this {WebInspector.NetworkRequest} | 977 * @this {SDK.NetworkRequest} |
| 978 */ | 978 */ |
| 979 function onResourceContent(content) { | 979 function onResourceContent(content) { |
| 980 var imageSrc = WebInspector.ContentProvider.contentAsDataURL(content, this
._mimeType, true); | 980 var imageSrc = Common.ContentProvider.contentAsDataURL(content, this._mime
Type, true); |
| 981 if (imageSrc === null) | 981 if (imageSrc === null) |
| 982 imageSrc = this._url; | 982 imageSrc = this._url; |
| 983 image.src = imageSrc; | 983 image.src = imageSrc; |
| 984 } | 984 } |
| 985 | 985 |
| 986 this.requestContent().then(onResourceContent.bind(this)); | 986 this.requestContent().then(onResourceContent.bind(this)); |
| 987 } | 987 } |
| 988 | 988 |
| 989 /** | 989 /** |
| 990 * @return {?string} | 990 * @return {?string} |
| 991 */ | 991 */ |
| 992 asDataURL() { | 992 asDataURL() { |
| 993 var content = this._content; | 993 var content = this._content; |
| 994 var charset = null; | 994 var charset = null; |
| 995 if (!this._contentEncoded) { | 995 if (!this._contentEncoded) { |
| 996 content = content.toBase64(); | 996 content = content.toBase64(); |
| 997 charset = 'utf-8'; | 997 charset = 'utf-8'; |
| 998 } | 998 } |
| 999 return WebInspector.ContentProvider.contentAsDataURL(content, this.mimeType,
true, charset); | 999 return Common.ContentProvider.contentAsDataURL(content, this.mimeType, true,
charset); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 _innerRequestContent() { | 1002 _innerRequestContent() { |
| 1003 if (this._contentRequested) | 1003 if (this._contentRequested) |
| 1004 return; | 1004 return; |
| 1005 this._contentRequested = true; | 1005 this._contentRequested = true; |
| 1006 | 1006 |
| 1007 /** | 1007 /** |
| 1008 * @param {?Protocol.Error} error | 1008 * @param {?Protocol.Error} error |
| 1009 * @param {string} content | 1009 * @param {string} content |
| 1010 * @param {boolean} contentEncoded | 1010 * @param {boolean} contentEncoded |
| 1011 * @this {WebInspector.NetworkRequest} | 1011 * @this {SDK.NetworkRequest} |
| 1012 */ | 1012 */ |
| 1013 function onResourceContent(error, content, contentEncoded) { | 1013 function onResourceContent(error, content, contentEncoded) { |
| 1014 this._content = error ? null : content; | 1014 this._content = error ? null : content; |
| 1015 this._contentError = error; | 1015 this._contentError = error; |
| 1016 this._contentEncoded = contentEncoded; | 1016 this._contentEncoded = contentEncoded; |
| 1017 var callbacks = this._pendingContentCallbacks.slice(); | 1017 var callbacks = this._pendingContentCallbacks.slice(); |
| 1018 for (var i = 0; i < callbacks.length; ++i) | 1018 for (var i = 0; i < callbacks.length; ++i) |
| 1019 callbacks[i](this._content); | 1019 callbacks[i](this._content); |
| 1020 this._pendingContentCallbacks.length = 0; | 1020 this._pendingContentCallbacks.length = 0; |
| 1021 delete this._contentRequested; | 1021 delete this._contentRequested; |
| 1022 } | 1022 } |
| 1023 this.target().networkAgent().getResponseBody(this._requestId, onResourceCont
ent.bind(this)); | 1023 this.target().networkAgent().getResponseBody(this._requestId, onResourceCont
ent.bind(this)); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 /** | 1026 /** |
| 1027 * @return {?Protocol.Network.Initiator} | 1027 * @return {?Protocol.Network.Initiator} |
| 1028 */ | 1028 */ |
| 1029 initiator() { | 1029 initiator() { |
| 1030 return this._initiator; | 1030 return this._initiator; |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 /** | 1033 /** |
| 1034 * @return {!{type: !WebInspector.NetworkRequest.InitiatorType, url: string, l
ineNumber: number, columnNumber: number, scriptId: ?string}} | 1034 * @return {!{type: !SDK.NetworkRequest.InitiatorType, url: string, lineNumber
: number, columnNumber: number, scriptId: ?string}} |
| 1035 */ | 1035 */ |
| 1036 initiatorInfo() { | 1036 initiatorInfo() { |
| 1037 if (this._initiatorInfo) | 1037 if (this._initiatorInfo) |
| 1038 return this._initiatorInfo; | 1038 return this._initiatorInfo; |
| 1039 | 1039 |
| 1040 var type = WebInspector.NetworkRequest.InitiatorType.Other; | 1040 var type = SDK.NetworkRequest.InitiatorType.Other; |
| 1041 var url = ''; | 1041 var url = ''; |
| 1042 var lineNumber = -Infinity; | 1042 var lineNumber = -Infinity; |
| 1043 var columnNumber = -Infinity; | 1043 var columnNumber = -Infinity; |
| 1044 var scriptId = null; | 1044 var scriptId = null; |
| 1045 var initiator = this._initiator; | 1045 var initiator = this._initiator; |
| 1046 | 1046 |
| 1047 if (this.redirectSource) { | 1047 if (this.redirectSource) { |
| 1048 type = WebInspector.NetworkRequest.InitiatorType.Redirect; | 1048 type = SDK.NetworkRequest.InitiatorType.Redirect; |
| 1049 url = this.redirectSource.url; | 1049 url = this.redirectSource.url; |
| 1050 } else if (initiator) { | 1050 } else if (initiator) { |
| 1051 if (initiator.type === Protocol.Network.InitiatorType.Parser) { | 1051 if (initiator.type === Protocol.Network.InitiatorType.Parser) { |
| 1052 type = WebInspector.NetworkRequest.InitiatorType.Parser; | 1052 type = SDK.NetworkRequest.InitiatorType.Parser; |
| 1053 url = initiator.url ? initiator.url : url; | 1053 url = initiator.url ? initiator.url : url; |
| 1054 lineNumber = initiator.lineNumber ? initiator.lineNumber : lineNumber; | 1054 lineNumber = initiator.lineNumber ? initiator.lineNumber : lineNumber; |
| 1055 } else if (initiator.type === Protocol.Network.InitiatorType.Script) { | 1055 } else if (initiator.type === Protocol.Network.InitiatorType.Script) { |
| 1056 for (var stack = initiator.stack; stack; stack = stack.parent) { | 1056 for (var stack = initiator.stack; stack; stack = stack.parent) { |
| 1057 var topFrame = stack.callFrames.length ? stack.callFrames[0] : null; | 1057 var topFrame = stack.callFrames.length ? stack.callFrames[0] : null; |
| 1058 if (!topFrame) | 1058 if (!topFrame) |
| 1059 continue; | 1059 continue; |
| 1060 type = WebInspector.NetworkRequest.InitiatorType.Script; | 1060 type = SDK.NetworkRequest.InitiatorType.Script; |
| 1061 url = topFrame.url || WebInspector.UIString('<anonymous>'); | 1061 url = topFrame.url || Common.UIString('<anonymous>'); |
| 1062 lineNumber = topFrame.lineNumber; | 1062 lineNumber = topFrame.lineNumber; |
| 1063 columnNumber = topFrame.columnNumber; | 1063 columnNumber = topFrame.columnNumber; |
| 1064 scriptId = topFrame.scriptId; | 1064 scriptId = topFrame.scriptId; |
| 1065 break; | 1065 break; |
| 1066 } | 1066 } |
| 1067 } | 1067 } |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 this._initiatorInfo = | 1070 this._initiatorInfo = |
| 1071 {type: type, url: url, lineNumber: lineNumber, columnNumber: columnNumbe
r, scriptId: scriptId}; | 1071 {type: type, url: url, lineNumber: lineNumber, columnNumber: columnNumbe
r, scriptId: scriptId}; |
| 1072 return this._initiatorInfo; | 1072 return this._initiatorInfo; |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 /** | 1075 /** |
| 1076 * @return {?WebInspector.NetworkRequest} | 1076 * @return {?SDK.NetworkRequest} |
| 1077 */ | 1077 */ |
| 1078 initiatorRequest() { | 1078 initiatorRequest() { |
| 1079 if (this._initiatorRequest === undefined) | 1079 if (this._initiatorRequest === undefined) |
| 1080 this._initiatorRequest = this._networkLog.requestForURL(this.initiatorInfo
().url); | 1080 this._initiatorRequest = this._networkLog.requestForURL(this.initiatorInfo
().url); |
| 1081 return this._initiatorRequest; | 1081 return this._initiatorRequest; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 /** | 1084 /** |
| 1085 * @return {!WebInspector.NetworkRequest.InitiatorGraph} | 1085 * @return {!SDK.NetworkRequest.InitiatorGraph} |
| 1086 */ | 1086 */ |
| 1087 initiatorGraph() { | 1087 initiatorGraph() { |
| 1088 var initiated = new Set(); | 1088 var initiated = new Set(); |
| 1089 var requests = this._networkLog.requests(); | 1089 var requests = this._networkLog.requests(); |
| 1090 for (var request of requests) { | 1090 for (var request of requests) { |
| 1091 var localInitiators = request._initiatorChain(); | 1091 var localInitiators = request._initiatorChain(); |
| 1092 if (localInitiators.has(this)) | 1092 if (localInitiators.has(this)) |
| 1093 initiated.add(request); | 1093 initiated.add(request); |
| 1094 } | 1094 } |
| 1095 return {initiators: this._initiatorChain(), initiated: initiated}; | 1095 return {initiators: this._initiatorChain(), initiated: initiated}; |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 /** | 1098 /** |
| 1099 * @return {!Set<!WebInspector.NetworkRequest>} | 1099 * @return {!Set<!SDK.NetworkRequest>} |
| 1100 */ | 1100 */ |
| 1101 _initiatorChain() { | 1101 _initiatorChain() { |
| 1102 if (this._initiatorChainCache) | 1102 if (this._initiatorChainCache) |
| 1103 return this._initiatorChainCache; | 1103 return this._initiatorChainCache; |
| 1104 this._initiatorChainCache = new Set(); | 1104 this._initiatorChainCache = new Set(); |
| 1105 var request = this; | 1105 var request = this; |
| 1106 while (request) { | 1106 while (request) { |
| 1107 this._initiatorChainCache.add(request); | 1107 this._initiatorChainCache.add(request); |
| 1108 request = request.initiatorRequest(); | 1108 request = request.initiatorRequest(); |
| 1109 } | 1109 } |
| 1110 return this._initiatorChainCache; | 1110 return this._initiatorChainCache; |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 /** | 1113 /** |
| 1114 * @return {!Array.<!WebInspector.NetworkRequest.WebSocketFrame>} | 1114 * @return {!Array.<!SDK.NetworkRequest.WebSocketFrame>} |
| 1115 */ | 1115 */ |
| 1116 frames() { | 1116 frames() { |
| 1117 return this._frames; | 1117 return this._frames; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 /** | 1120 /** |
| 1121 * @param {string} errorMessage | 1121 * @param {string} errorMessage |
| 1122 * @param {number} time | 1122 * @param {number} time |
| 1123 */ | 1123 */ |
| 1124 addFrameError(errorMessage, time) { | 1124 addFrameError(errorMessage, time) { |
| 1125 this._addFrame({ | 1125 this._addFrame({ |
| 1126 type: WebInspector.NetworkRequest.WebSocketFrameType.Error, | 1126 type: SDK.NetworkRequest.WebSocketFrameType.Error, |
| 1127 text: errorMessage, | 1127 text: errorMessage, |
| 1128 time: this.pseudoWallTime(time), | 1128 time: this.pseudoWallTime(time), |
| 1129 opCode: -1, | 1129 opCode: -1, |
| 1130 mask: false | 1130 mask: false |
| 1131 }); | 1131 }); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 /** | 1134 /** |
| 1135 * @param {!Protocol.Network.WebSocketFrame} response | 1135 * @param {!Protocol.Network.WebSocketFrame} response |
| 1136 * @param {number} time | 1136 * @param {number} time |
| 1137 * @param {boolean} sent | 1137 * @param {boolean} sent |
| 1138 */ | 1138 */ |
| 1139 addFrame(response, time, sent) { | 1139 addFrame(response, time, sent) { |
| 1140 var type = sent ? WebInspector.NetworkRequest.WebSocketFrameType.Send : | 1140 var type = sent ? SDK.NetworkRequest.WebSocketFrameType.Send : |
| 1141 WebInspector.NetworkRequest.WebSocketFrameType.Receive; | 1141 SDK.NetworkRequest.WebSocketFrameType.Receive; |
| 1142 this._addFrame({ | 1142 this._addFrame({ |
| 1143 type: type, | 1143 type: type, |
| 1144 text: response.payloadData, | 1144 text: response.payloadData, |
| 1145 time: this.pseudoWallTime(time), | 1145 time: this.pseudoWallTime(time), |
| 1146 opCode: response.opcode, | 1146 opCode: response.opcode, |
| 1147 mask: response.mask | 1147 mask: response.mask |
| 1148 }); | 1148 }); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 /** | 1151 /** |
| 1152 * @param {!WebInspector.NetworkRequest.WebSocketFrame} frame | 1152 * @param {!SDK.NetworkRequest.WebSocketFrame} frame |
| 1153 */ | 1153 */ |
| 1154 _addFrame(frame) { | 1154 _addFrame(frame) { |
| 1155 this._frames.push(frame); | 1155 this._frames.push(frame); |
| 1156 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.WebsocketFr
ameAdded, frame); | 1156 this.dispatchEventToListeners(SDK.NetworkRequest.Events.WebsocketFrameAdded,
frame); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 /** | 1159 /** |
| 1160 * @return {!Array.<!WebInspector.NetworkRequest.EventSourceMessage>} | 1160 * @return {!Array.<!SDK.NetworkRequest.EventSourceMessage>} |
| 1161 */ | 1161 */ |
| 1162 eventSourceMessages() { | 1162 eventSourceMessages() { |
| 1163 return this._eventSourceMessages; | 1163 return this._eventSourceMessages; |
| 1164 } | 1164 } |
| 1165 | 1165 |
| 1166 /** | 1166 /** |
| 1167 * @param {number} time | 1167 * @param {number} time |
| 1168 * @param {string} eventName | 1168 * @param {string} eventName |
| 1169 * @param {string} eventId | 1169 * @param {string} eventId |
| 1170 * @param {string} data | 1170 * @param {string} data |
| 1171 */ | 1171 */ |
| 1172 addEventSourceMessage(time, eventName, eventId, data) { | 1172 addEventSourceMessage(time, eventName, eventId, data) { |
| 1173 var message = {time: this.pseudoWallTime(time), eventName: eventName, eventI
d: eventId, data: data}; | 1173 var message = {time: this.pseudoWallTime(time), eventName: eventName, eventI
d: eventId, data: data}; |
| 1174 this._eventSourceMessages.push(message); | 1174 this._eventSourceMessages.push(message); |
| 1175 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.EventSource
MessageAdded, message); | 1175 this.dispatchEventToListeners(SDK.NetworkRequest.Events.EventSourceMessageAd
ded, message); |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 replayXHR() { | 1178 replayXHR() { |
| 1179 this.target().networkAgent().replayXHR(this.requestId); | 1179 this.target().networkAgent().replayXHR(this.requestId); |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 /** | 1182 /** |
| 1183 * @return {!WebInspector.NetworkLog} | 1183 * @return {!SDK.NetworkLog} |
| 1184 */ | 1184 */ |
| 1185 networkLog() { | 1185 networkLog() { |
| 1186 return this._networkLog; | 1186 return this._networkLog; |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 /** | 1189 /** |
| 1190 * @return {!WebInspector.NetworkManager} | 1190 * @return {!SDK.NetworkManager} |
| 1191 */ | 1191 */ |
| 1192 networkManager() { | 1192 networkManager() { |
| 1193 return this._networkManager; | 1193 return this._networkManager; |
| 1194 } | 1194 } |
| 1195 }; | 1195 }; |
| 1196 | 1196 |
| 1197 /** @enum {symbol} */ | 1197 /** @enum {symbol} */ |
| 1198 WebInspector.NetworkRequest.Events = { | 1198 SDK.NetworkRequest.Events = { |
| 1199 FinishedLoading: Symbol('FinishedLoading'), | 1199 FinishedLoading: Symbol('FinishedLoading'), |
| 1200 TimingChanged: Symbol('TimingChanged'), | 1200 TimingChanged: Symbol('TimingChanged'), |
| 1201 RemoteAddressChanged: Symbol('RemoteAddressChanged'), | 1201 RemoteAddressChanged: Symbol('RemoteAddressChanged'), |
| 1202 RequestHeadersChanged: Symbol('RequestHeadersChanged'), | 1202 RequestHeadersChanged: Symbol('RequestHeadersChanged'), |
| 1203 ResponseHeadersChanged: Symbol('ResponseHeadersChanged'), | 1203 ResponseHeadersChanged: Symbol('ResponseHeadersChanged'), |
| 1204 WebsocketFrameAdded: Symbol('WebsocketFrameAdded'), | 1204 WebsocketFrameAdded: Symbol('WebsocketFrameAdded'), |
| 1205 EventSourceMessageAdded: Symbol('EventSourceMessageAdded') | 1205 EventSourceMessageAdded: Symbol('EventSourceMessageAdded') |
| 1206 }; | 1206 }; |
| 1207 | 1207 |
| 1208 /** @enum {string} */ | 1208 /** @enum {string} */ |
| 1209 WebInspector.NetworkRequest.InitiatorType = { | 1209 SDK.NetworkRequest.InitiatorType = { |
| 1210 Other: 'other', | 1210 Other: 'other', |
| 1211 Parser: 'parser', | 1211 Parser: 'parser', |
| 1212 Redirect: 'redirect', | 1212 Redirect: 'redirect', |
| 1213 Script: 'script' | 1213 Script: 'script' |
| 1214 }; | 1214 }; |
| 1215 | 1215 |
| 1216 /** @typedef {!{name: string, value: string}} */ | 1216 /** @typedef {!{name: string, value: string}} */ |
| 1217 WebInspector.NetworkRequest.NameValue; | 1217 SDK.NetworkRequest.NameValue; |
| 1218 | 1218 |
| 1219 /** @enum {string} */ | 1219 /** @enum {string} */ |
| 1220 WebInspector.NetworkRequest.WebSocketFrameType = { | 1220 SDK.NetworkRequest.WebSocketFrameType = { |
| 1221 Send: 'send', | 1221 Send: 'send', |
| 1222 Receive: 'receive', | 1222 Receive: 'receive', |
| 1223 Error: 'error' | 1223 Error: 'error' |
| 1224 }; | 1224 }; |
| 1225 | 1225 |
| 1226 /** @typedef {!{type: WebInspector.NetworkRequest.WebSocketFrameType, time: numb
er, text: string, opCode: number, mask: boolean}} */ | 1226 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text:
string, opCode: number, mask: boolean}} */ |
| 1227 WebInspector.NetworkRequest.WebSocketFrame; | 1227 SDK.NetworkRequest.WebSocketFrame; |
| 1228 | 1228 |
| 1229 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}}
*/ | 1229 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}}
*/ |
| 1230 WebInspector.NetworkRequest.EventSourceMessage; | 1230 SDK.NetworkRequest.EventSourceMessage; |
| 1231 | 1231 |
| 1232 /** @typedef {!{initiators: !Set<!WebInspector.NetworkRequest>, initiated: !Set<
!WebInspector.NetworkRequest>}} */ | 1232 /** @typedef {!{initiators: !Set<!SDK.NetworkRequest>, initiated: !Set<!SDK.Netw
orkRequest>}} */ |
| 1233 WebInspector.NetworkRequest.InitiatorGraph; | 1233 SDK.NetworkRequest.InitiatorGraph; |
| OLD | NEW |