HTTP: Difference between revisions
Undo revision 315433 by WdeCvfYlmB (talk)
Thundergnat (talk | contribs) (Undo revision 315435 by WdeCvfYlmB (talk)) |
Thundergnat (talk | contribs) (Undo revision 315433 by WdeCvfYlmB (talk)) |
||
Line 832:
=={{header|F_Sharp|F#}}==
In F# we can just use the .NET library to do this so its the same as the [[C_sharp|C#]] example.
<lang fsharp>let wget (url : string) =▼
use c = new System.Net.WebClient()
c.DownloadString(url)
printfn "%s" (wget "http://www.
</lang>
However unlike C#, F# can use an asynchronous workflow to avoid blocking any threads while waiting for a response from the server. To asynchronously download three url's at once...
▲<lang fsharp>open System.Net
<lang fsharp>
open System.Net
open System.IO
let wgetAsync url =
use!
use responseStream = response.GetResponseStream()
return reader.ReadToEnd() }
let urls = ["http://www.rosettacode.org/"; "http://www.yahoo.com/"; "http://www.google.com/"]
let content = urls
|> List.map wgetAsync
Line 854 ⟶ 862:
=={{header|Factor}}==
<lang factor>USE: http.client
"http://www.
=={{header|Forth}}==
|