Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
1
Task/HTTP/8th/http.8th
Normal file
1
Task/HTTP/8th/http.8th
Normal file
|
|
@ -0,0 +1 @@
|
|||
"http://www.rosettacode.org" net:get drop >s .
|
||||
4
Task/HTTP/EchoLisp/http.echolisp
Normal file
4
Task/HTTP/EchoLisp/http.echolisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;; asynchronous call back definition
|
||||
(define (success name text) (writeln 'Loaded name) (writeln text))
|
||||
;;
|
||||
(file->string success "http://www.google.com")
|
||||
6
Task/HTTP/LFE/http-1.lfe
Normal file
6
Task/HTTP/LFE/http-1.lfe
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(: inets start)
|
||||
(case (: httpc request '"http://lfe.github.io")
|
||||
((tuple 'ok result)
|
||||
(: io format '"Result: ~p" (list result)))
|
||||
((tuple 'error reason)
|
||||
(: io format '"Error: ~p~n" (list reason))))
|
||||
13
Task/HTTP/LFE/http-2.lfe
Normal file
13
Task/HTTP/LFE/http-2.lfe
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(: inets start)
|
||||
(let* ((method 'get)
|
||||
(url '"http://lfe.github.io")
|
||||
(headers ())
|
||||
(request-data (tuple url headers))
|
||||
(http-options ())
|
||||
(request-options (list (tuple 'sync 'false))))
|
||||
(: httpc request method request-data http-options request-options)
|
||||
(receive
|
||||
((tuple 'http (tuple request-id (tuple 'error reason)))
|
||||
(: io format '"Error: ~p~n" (list reason)))
|
||||
((tuple 'http (tuple request-id result))
|
||||
(: io format '"Result: ~p~n" (list result))))))
|
||||
10
Task/HTTP/Lasso/http.lasso
Normal file
10
Task/HTTP/Lasso/http.lasso
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// using include_url wrapper:
|
||||
include_url('http://rosettacode.org/index.html')
|
||||
|
||||
// one line curl
|
||||
curl('http://rosettacode.org/index')->result->asString
|
||||
|
||||
// using curl for more complex operations and feedback
|
||||
local(x = curl('http://rosettacode.org/index'))
|
||||
local(y = #x->result)
|
||||
#y->asString
|
||||
30
Task/HTTP/Lingo/http-1.lingo
Normal file
30
Task/HTTP/Lingo/http-1.lingo
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
property _netID
|
||||
property _cbHandler
|
||||
property _cbTarget
|
||||
|
||||
----------------------------------------
|
||||
-- Simple HTTP GET request
|
||||
-- @param {string} url
|
||||
-- @param {symbol} cbHandler
|
||||
-- @param {object} [cbTarget=_movie]
|
||||
----------------------------------------
|
||||
on new (me, url, cbHandler, cbTarget)
|
||||
if voidP(cbTarget) then cbTarget = _movie
|
||||
me._netID = getNetText(url)
|
||||
me._cbHandler = cbHandler
|
||||
me._cbTarget = cbTarget
|
||||
_movie.actorList.add(me)
|
||||
return me
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
-- @callback
|
||||
----------------------------------------
|
||||
on stepFrame (me)
|
||||
if netDone(me._netID) then
|
||||
res = netTextResult(me._netID)
|
||||
err = netError(me._netID)
|
||||
_movie.actorList.deleteOne(me)
|
||||
call(me._cbHandler, me._cbTarget, res, err)
|
||||
end if
|
||||
end
|
||||
17
Task/HTTP/Lingo/http-2.lingo
Normal file
17
Task/HTTP/Lingo/http-2.lingo
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
----------------------------------------
|
||||
--
|
||||
----------------------------------------
|
||||
on getAdobeHomePage ()
|
||||
script("SimpleHttpGet").new("http://www.adobe.com/", #printResult)
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
-- @callback
|
||||
----------------------------------------
|
||||
on printResult (res, err)
|
||||
if err="OK" then
|
||||
put res
|
||||
else
|
||||
put "Network Error:" && err
|
||||
end if
|
||||
end
|
||||
3
Task/HTTP/Lingo/http-3.lingo
Normal file
3
Task/HTTP/Lingo/http-3.lingo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
getAdobeHomePage()
|
||||
-- "<!doctype html>
|
||||
...
|
||||
3
Task/HTTP/LiveCode/http-1.livecode
Normal file
3
Task/HTTP/LiveCode/http-1.livecode
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
put true into libURLFollowHttpRedirects
|
||||
get URL "http://httpbin.org/html"
|
||||
put it
|
||||
7
Task/HTTP/LiveCode/http-2.livecode
Normal file
7
Task/HTTP/LiveCode/http-2.livecode
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
on myUrlDownloadFinished
|
||||
answer "Download Complete" with "Okay"
|
||||
end myUrlDownloadFinished
|
||||
|
||||
command getWebResource
|
||||
load URL "http://httpbin.org/html" with message "myUrlDownloadFinished"
|
||||
end getWebResource
|
||||
3
Task/HTTP/Nim/http.nim
Normal file
3
Task/HTTP/Nim/http.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import httpclient
|
||||
|
||||
echo getContent "http://rosettacode.org"
|
||||
1
Task/HTTP/Peloton/http-1.peloton
Normal file
1
Task/HTTP/Peloton/http-1.peloton
Normal file
|
|
@ -0,0 +1 @@
|
|||
<@ SAYURLLIT>http://rosettacode.org/wiki/Main_Page</@>
|
||||
1
Task/HTTP/Peloton/http-2.peloton
Normal file
1
Task/HTTP/Peloton/http-2.peloton
Normal file
|
|
@ -0,0 +1 @@
|
|||
<# SAY URLSOURCE LITERAL>http://rosettacode.org/wiki/Main_Page</#>
|
||||
1
Task/HTTP/Ring/http.ring
Normal file
1
Task/HTTP/Ring/http.ring
Normal file
|
|
@ -0,0 +1 @@
|
|||
See download("http://rosettacode.org")
|
||||
13
Task/HTTP/Sidef/http.sidef
Normal file
13
Task/HTTP/Sidef/http.sidef
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
func get(url) {
|
||||
var lwp = (
|
||||
try { require('LWP::UserAgent') }
|
||||
catch { warn "'LWP::UserAgent' is not installed!"; return }
|
||||
);
|
||||
var ua = lwp.new(agent => 'Mozilla/5.0');
|
||||
if (var resp = ua.get(url); resp.is_success) {
|
||||
return resp.decoded_content;
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
print get("http://rosettacode.org");
|
||||
15
Task/HTTP/Swift/http.swift
Normal file
15
Task/HTTP/Swift/http.swift
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import Foundation
|
||||
|
||||
let request = NSURLRequest(URL: NSURL(string: "http://rosettacode.org/")!)
|
||||
|
||||
// Using trailing closure
|
||||
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue()) {res, data, err in
|
||||
|
||||
// data is binary
|
||||
if (data != nil) {
|
||||
let string = NSString(data: data!, encoding: NSUTF8StringEncoding)
|
||||
println(string)
|
||||
}
|
||||
}
|
||||
|
||||
CFRunLoopRun() // dispatch
|
||||
Loading…
Add table
Add a link
Reference in a new issue