| <html> |
| <head> |
| <script src="../http/tests/inspector/inspector-test.js"></script> |
| <script type="text/javascript"> |
| |
| var test = function() |
| { |
| var logView = WebInspector.panel("network")._networkLogView; |
| |
| function newRequest(headers, data) |
| { |
| var request = new WebInspector.NetworkRequest(0, "http://example.org/path", 0, 0, 0); |
| request.requestMethod = data ? "POST" : "GET"; |
| var headerList = []; |
| if (headers) { |
| for (var i in headers) |
| headerList.push({name: i, value: headers[i]}); |
| } |
| if (data) { |
| headerList.push({name: "Content-Length", value: data.length}); |
| request.requestFormData = data; |
| } |
| request.requestHeaders = headerList; |
| return request; |
| } |
| |
| function dumpRequest(headers, data) |
| { |
| InspectorTest.addResult(logView._generateCurlCommand(newRequest(headers, data))); |
| } |
| |
| dumpRequest({}) |
| dumpRequest({}, "123"); |
| dumpRequest({"Content-Type": "application/x-www-form-urlencoded"}, "1&b"); |
| dumpRequest({"Content-Type": "application/json"}, "{\"a\":1}"); |
| |
| InspectorTest.completeTest(); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests curl command generation</p> |
| </body> |
| </html> |