3 <script src=
"../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../http/tests/inspector/network-test.js"></script>
5 <script type=
"text/javascript">
9 var logView
= WebInspector
.panels
.network
._networkLogView
;
11 function newRequest(headers
, data
, opt_url
)
13 var request
= new WebInspector
.NetworkRequest(WebInspector
.targetManager
.mainTarget(), 0, opt_url
|| 'http://example.org/path', 0, 0, 0);
14 request
.requestMethod
= data
? "POST" : "GET";
17 for (var i
in headers
)
18 headerList
.push({name
: i
, value
: headers
[i
]});
21 headerList
.push({name
: "Content-Length", value
: data
.length
});
22 request
.requestFormData
= data
;
24 request
.setRequestHeaders(headerList
);
28 function dumpRequest(headers
, data
, opt_url
)
30 InspectorTest
.addResult(logView
._generateCurlCommand(newRequest(headers
, data
, opt_url
), WebInspector
.isWin() ? "win" : "unix"));
34 dumpRequest({}, "123");
35 dumpRequest({"Content-Type": "application/x-www-form-urlencoded"}, "1&b");
36 dumpRequest({"Content-Type": "application/json"}, "{\"a\":1}");
37 dumpRequest({"Content-Type": "application/binary"}, "1234\r\n\x30\x30\2\3\4\5\'\"!"); // expected content length: 15
38 dumpRequest({"Content-Type": "application/binary"}, "1234\r\n\1\x30\x30\2\3\4\5\'\"!"); // expected content length: 16
39 dumpRequest({"Content-Type": "application/binary"}, "\x7F\x80\x90\xFF\u0009\u0700");
40 dumpRequest({}, "", "http://labs.ft.com/?querystring=[]{}"); // Character range symbols must be escaped (http://crbug.com/265449).
41 dumpRequest({"Content-Type": "application/binary"}, "%PATH%$PATH");
42 dumpRequest({":host": "h", "version": "v"});
44 InspectorTest
.completeTest();
49 <body onload=
"runTest()">
50 <p>Tests curl command generation
</p>