WebKit Bugzilla
Attachment 361139 Details for
Bug 194261
: Web Inspector: add context menu items to copy a resource's HTTP request/response data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194261-20190204172853.patch (text/plain), 5.72 KB, created by
Devin Rousso
on 2019-02-04 17:28:54 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-02-04 17:28:54 PST
Size:
5.72 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index bcd979d271b1ae6e229fdcf4ff46e0a8533ec51b..4107b3da78245f19ba58401b565f17844addfdfe 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,22 @@ >+2019-02-04 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: add context menu items to copy a resource's HTTP request/response data >+ https://bugs.webkit.org/show_bug.cgi?id=194261 >+ <rdar://problem/21693696> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UserInterface/Models/Resource.js: >+ (WI.Resource.prototype.stringifyHTTPRequest): Added. >+ (WI.Resource.prototype.stringifyHTTPResponse): Added. >+ Don't include the request/response data, as that can be very large, and can easily be >+ accessed by actually selecting the resource in the Resources/Network tab. >+ >+ * UserInterface/Views/ContextMenuUtilities.js: >+ (WI.appendContextMenuItemsForSourceCode): >+ >+ * Localizations/en.lproj/localizedStrings.js: >+ > 2019-02-01 Devin Rousso <drousso@apple.com> > > Web Inspector: create icons for media event types instead of using a blue circle >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index d8c79558caadaefbeb25f954bdbfb8499d5091ad..d6a61cfdd706e27e30dda8359d79c7c7392e069b 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -257,6 +257,8 @@ localizedStrings["Controls"] = "Controls"; > localizedStrings["Cookies"] = "Cookies"; > localizedStrings["Copy"] = "Copy"; > localizedStrings["Copy Action"] = "Copy Action"; >+localizedStrings["Copy HTTP Request"] = "Copy HTTP Request"; >+localizedStrings["Copy HTTP Response"] = "Copy HTTP Response"; > localizedStrings["Copy Link"] = "Copy Link"; > localizedStrings["Copy Path to Property"] = "Copy Path to Property"; > localizedStrings["Copy Row"] = "Copy Row"; >diff --git a/Source/WebInspectorUI/UserInterface/Models/Resource.js b/Source/WebInspectorUI/UserInterface/Models/Resource.js >index 66bc65b46dfd2ea12d6b24c807dcdfc45b2b62bf..0d8714595082f0b2087bdbba3586309c935a49b8 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/Resource.js >+++ b/Source/WebInspectorUI/UserInterface/Models/Resource.js >@@ -1061,9 +1061,52 @@ WI.Resource = class Resource extends WI.SourceCode > command.push("--data-binary " + escapeStringPosix(this.requestData)); > } > >- let curlCommand = command.join(" \\\n"); >- InspectorFrontendHost.copyText(curlCommand); >- return curlCommand; >+ return command.join(" \\\n"); >+ } >+ >+ stringifyHTTPRequest() >+ { >+ let lines = []; >+ >+ let protocol = this.protocol || ""; >+ if (protocol === "h2") { >+ // HTTP/2 Request pseudo headers: >+ // https://tools.ietf.org/html/rfc7540#section-8.1.2.3 >+ lines.push(`:method: ${this.requestMethod}`); >+ lines.push(`:scheme: ${this.urlComponents.scheme}`); >+ lines.push(`:authority: ${WI.h2Authority(this.urlComponents)}`); >+ lines.push(`:path: ${WI.h2Path(this.urlComponents)}`); >+ } else { >+ // HTTP/1.1 request line: >+ // https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1 >+ lines.push(`${this.requestMethod} ${this.urlComponents.path}${protocol ? " " + protocol.toUpperCase() : ""}`); >+ } >+ >+ for (let key in this.requestHeaders) >+ lines.push(`${key}: ${this.requestHeaders[key]}`); >+ >+ return lines.join("\n") + "\n"; >+ } >+ >+ stringifyHTTPResponse() >+ { >+ let lines = []; >+ >+ let protocol = this.protocol || ""; >+ if (protocol === "h2") { >+ // HTTP/2 Response pseudo headers: >+ // https://tools.ietf.org/html/rfc7540#section-8.1.2.4 >+ lines.push(`:status: ${this.statusCode}`); >+ } else { >+ // HTTP/1.1 response status line: >+ // https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1 >+ lines.push(`${protocol ? protocol.toUpperCase() + " " : ""}${this.statusCode} ${this.statusText}`); >+ } >+ >+ for (let key in this.responseHeaders) >+ lines.push(`${key}: ${this.responseHeaders[key]}`); >+ >+ return lines.join("\n") + "\n"; > } > > async showCertificate() >diff --git a/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js b/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js >index b543529f5c1c0198999fa4b58e9da5038958fd9b..9123d0c3df6ab45be724d156ecc04f6319919ee0 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js >+++ b/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js >@@ -47,8 +47,22 @@ WI.appendContextMenuItemsForSourceCode = function(contextMenu, sourceCodeOrLocat > if (sourceCode instanceof WI.Resource) { > if (sourceCode.urlComponents.scheme !== "data") { > contextMenu.appendItem(WI.UIString("Copy as cURL"), () => { >- sourceCode.generateCURLCommand(); >+ InspectorFrontendHost.copyText(sourceCode.generateCURLCommand()); > }); >+ >+ contextMenu.appendSeparator(); >+ >+ contextMenu.appendItem(WI.UIString("Copy HTTP Request"), () => { >+ InspectorFrontendHost.copyText(sourceCode.stringifyHTTPRequest()); >+ }); >+ >+ if (sourceCode.hasResponse()) { >+ contextMenu.appendItem(WI.UIString("Copy HTTP Response"), () => { >+ InspectorFrontendHost.copyText(sourceCode.stringifyHTTPResponse()); >+ }); >+ } >+ >+ contextMenu.appendSeparator(); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194261
: 361139