Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
35
Task/HTTP/JavaScript/http.js
Normal file
35
Task/HTTP/JavaScript/http.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
((function(url,callback,method,post,headers){//headers is an object like this {Connection:"keep-alive"}
|
||||
function createXMLHttpRequest() {
|
||||
if (typeof XMLHttpRequest != "undefined") {
|
||||
return new XMLHttpRequest();
|
||||
} else if (typeof window.ActiveXObject != "undefined") {
|
||||
try {
|
||||
return new ActiveXObject("Msxml2.XMLHTTP.4.0");
|
||||
} catch (e) {
|
||||
try {
|
||||
return new ActiveXObject("MSXML2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
return new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function looProp(object,callback){
|
||||
var a;
|
||||
for(a in object){
|
||||
if(object.hasOwnProperty(a))callback.call(object,a,object[a]);
|
||||
}
|
||||
}
|
||||
method=method||"GET";
|
||||
var xhr=createXMLHttpRequest();
|
||||
if(xhr){
|
||||
xhr.open(method,url,true);
|
||||
looProp(headers,function(a,b){xhr.setRequestHeader(a,b)})
|
||||
xhr.onreadystatechange=function(){if(xhr.readyState==xhr.DONE){callback(xhr)}};
|
||||
xhr.send(post);
|
||||
return xhr;}else{return null;}
|
||||
})('http://rosettacode.org',function(xhr){console.log(xhr.responseText)}))
|
||||
3
Task/HTTP/Julia/http.julia
Normal file
3
Task/HTTP/Julia/http.julia
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
readurl(url) = open(readlines, download(url))
|
||||
|
||||
readurl("http://rosettacode.org/index.html")
|
||||
17
Task/HTTP/Nemerle/http.nemerle
Normal file
17
Task/HTTP/Nemerle/http.nemerle
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Console;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
|
||||
module HTTP
|
||||
{
|
||||
Main() : void
|
||||
{
|
||||
def wc = WebClient();
|
||||
def myStream = wc.OpenRead("http://rosettacode.org");
|
||||
def sr = StreamReader(myStream);
|
||||
|
||||
WriteLine(sr.ReadToEnd());
|
||||
myStream.Close()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
use Net;
|
||||
use Structure;
|
||||
use HTTP;
|
||||
use Collection;
|
||||
|
||||
bundle Default {
|
||||
class HttpTest {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
client := HttpClient->New("http://rosettacode.org", 80);
|
||||
lines := client->Get();
|
||||
each(i : lines) {
|
||||
lines->GetValue(i)->As(String)->PrintLine();
|
||||
};
|
||||
}
|
||||
class HttpTest {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
lines := HttpClient->New()->Get("http://rosettacode.org");
|
||||
each(i : lines) {
|
||||
lines->Get(i)->As(String)->PrintLine();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
import scala.io._
|
||||
import scala.io.Source
|
||||
|
||||
object HttpTest {
|
||||
def main(args: Array[String]): Unit = {
|
||||
//if you are behind a firewall you can configure your proxy
|
||||
System.setProperty("http.proxySet", "true")
|
||||
System.setProperty("http.proxyHost", "0.0.0.0")
|
||||
System.setProperty("http.proxyPort", "8080")
|
||||
|
||||
Source.fromURL("http://www.rosettacode.org").getLines.foreach(println)
|
||||
}
|
||||
object HttpTest extends App {
|
||||
System.setProperty("http.agent", "*")
|
||||
|
||||
Source.fromURL("http://www.rosettacode.org").getLines.foreach(println)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue