Changeset 140391 in webkit
- Timestamp:
- Jan 22, 2013 12:13:08 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r140385 r140391 1 2013-01-22 Sergey Ryazanov <serya@chromium.org> 2 3 Web Inspector: Show requests in `curl` syntax in DevTools → Network → Headers 4 https://bugs.webkit.org/show_bug.cgi?id=107276 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/curl-command-expected.txt: Added. 9 * inspector/curl-command.html: Added. 10 1 11 2013-01-21 Kent Tamura <tkent@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r140390 r140391 1 2013-01-22 Sergey Ryazanov <serya@chromium.org> 2 3 Web Inspector: Show requests in `curl` syntax in DevTools → Network → Headers 4 https://bugs.webkit.org/show_bug.cgi?id=107276 5 6 Reviewed by Pavel Feldman. 7 8 Test: inspector/curl-command.html 9 10 * inspector/front-end/NetworkPanel.js: 11 (WebInspector.NetworkLogView.prototype._generateCurlCommand): 12 1 13 2013-01-22 Yury Semikhatsky <yurys@chromium.org> 2 14 -
trunk/Source/WebCore/English.lproj/localizedStrings.js
r140160 r140391 134 134 localizedStrings["Copy response headers"] = "Copy response headers"; 135 135 localizedStrings["Copy Response Headers"] = "Copy Response Headers"; 136 localizedStrings["Copy as curl"] = "Copy as curl"; 137 localizedStrings["Copy as Curl"] = "Copy as Curl"; 136 138 localizedStrings["Copy XPath"] = "Copy XPath"; 137 139 localizedStrings["Web SQL"] = "Web SQL"; -
trunk/Source/WebCore/inspector/front-end/NetworkPanel.js
r140107 r140391 1002 1002 if (request.responseHeadersText) 1003 1003 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy response headers" : "Copy Response Headers"), this._copyResponseHeaders.bind(this, request)); 1004 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy as curl" : "Copy as Curl"), this._copyCurlCommand.bind(this, request)); 1004 1005 } 1005 1006 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy all as HAR" : "Copy All as HAR"), this._copyAll.bind(this)); … … 1053 1054 { 1054 1055 InspectorFrontendHost.copyText(request.responseHeadersText); 1056 }, 1057 1058 /** 1059 * @param {WebInspector.NetworkRequest} request 1060 */ 1061 _copyCurlCommand: function(request) 1062 { 1063 InspectorFrontendHost.copyText(this._generateCurlCommand(request)); 1055 1064 }, 1056 1065 … … 1322 1331 this._highlightedNode = node; 1323 1332 }, 1333 1334 /** 1335 * @param {WebInspector.NetworkRequest} request 1336 * @return {string} 1337 */ 1338 _generateCurlCommand: function(request) 1339 { 1340 var command = ["curl"]; 1341 var ignoredHeaders = {}; 1342 1343 function escape(str) 1344 { 1345 return "\"" + str.replace(/\\/g, "\\\\") 1346 .replace(/\"/g, "\\\"") 1347 .replace(/\$/g, "\\$") 1348 .replace(/\n/g, "\\\n") 1349 .replace(/\`/g, "\\\`") + "\""; 1350 } 1351 command.push(escape(request.url)); 1352 1353 var inferredMethod = "GET"; 1354 var data = []; 1355 var requestContentType = request.requestContentType(); 1356 if (requestContentType && requestContentType.startsWith("application/x-www-form-urlencoded") && request.requestFormData) { 1357 data.push("--data"); 1358 data.push(escape(request.requestFormData)); 1359 ignoredHeaders["Content-Length"] = true; 1360 inferredMethod = "POST"; 1361 } else if (request.requestFormData) { 1362 data.push("--data-binary"); 1363 data.push(escape(request.requestFormData)); 1364 ignoredHeaders["Content-Length"] = true; 1365 inferredMethod = "POST"; 1366 } 1367 1368 if (request.requestMethod !== inferredMethod) { 1369 command.push("-X"); 1370 command.push(request.requestMethod); 1371 } 1372 1373 for (var i = 0; i < request.requestHeaders.length; i++) { 1374 var header = request.requestHeaders[i]; 1375 if (header.name in ignoredHeaders) 1376 continue; 1377 command.push("-H"); 1378 command.push(escape(header.name + ": " + header.value)); 1379 } 1380 command = command.concat(data); 1381 return command.join(" "); 1382 }, 1324 1383 1325 1384 __proto__: WebInspector.View.prototype
Note: See TracChangeset
for help on using the changeset viewer.