turtlestitch/libraries/httpBlocks.xml

4 wiersze
1.8 KiB
XML

<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="%&apos;method&apos; url: %&apos;url&apos; send: %&apos;payload&apos; headers: %&apos;headers&apos;" type="reporter" category="sensing"><header></header><code></code><inputs><input type="%s" readonly="true">GET<options>GET
POST
PUT
DELETE</options></input><input type="%s">http://snap.berkeley.edu</input><input type="%s"></input><input type="%mult%l" readonly="true"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>method</l><l>url</l><l>data</l><l>headers</l><l>proc</l></list><l>var response, i, header;&#xD;if (!proc.httpRequest) {&#xD; proc.httpRequest = new XMLHttpRequest();&#xD; proc.httpRequest.open(method, url, true);&#xD; proc.assertType(headers, &apos;list&apos;);&#xD; for (i = 1; i &lt;= headers.length(); i += 1) {&#xD; header = headers.at(i);&#xD; proc.assertType(header, &apos;list&apos;);&#xD; proc.httpRequest.setRequestHeader(&#xD; header.at(1),&#xD; header.at(2)&#xD; );&#xD; }&#xD; proc.httpRequest.send(data || null);&#xD;} else if (proc.httpRequest.readyState === 4) {&#xD; response = proc.httpRequest.responseText;&#xD; proc.httpRequest = null;&#xD; return response;&#xD;}&#xD;proc.pushContext(&apos;doYield&apos;);&#xD;proc.pushContext();</l></block><list><block var="method"/><block var="url"/><block var="payload"/><block var="headers"/></list></block></block></script></block-definition><block-definition s="key: %&apos;key&apos; value: %&apos;value&apos;" type="reporter" category="operators"><header></header><code></code><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><block var="key"/><block var="value"/></list></block></block></script></block-definition></blocks>