1 import std.json; 2 import std.string; 3 import std.stdio; 4 import std.range; 5 import std.process; 6 7 //globalLogLevel(LogLevel.info); 8 //// while we have no internal ftp server we can run tests in non-reloable networking environment 9 //immutable unreliable_network = environment.get("UNRELIABLENETWORK", "false") == "true"; 10 // 11 ///// ftp upload from range 12 //info("Test getContent(ftp)"); 13 //auto r = getContent("ftp://speedtest.tele2.net/1KB.zip"); 14 //assert(unreliable_network || r.length == 1024); 15 // 16 //info("Test receiveAsRange with GET(ftp)"); 17 //ubyte[] streamedContent; 18 //auto rq = Request(); 19 //rq.useStreaming = true; 20 //streamedContent.length = 0; 21 //auto rs = rq.get("ftp://speedtest.tele2.net/1KB.zip"); 22 //auto stream = rs.receiveAsRange; 23 //while( !stream.empty() ) { 24 // streamedContent ~= stream.front; 25 // stream.popFront(); 26 //} 27 //assert(unreliable_network || streamedContent.length == 1024); 28 //info("Test postContent ftp"); 29 //r = postContent("ftp://speedtest.tele2.net/upload/TEST.TXT", "test, ignore please\n".representation); 30 //assert(unreliable_network || r.length == 0); 31 // 32 //// 33 //info("ftp post ", "ftp://speedtest.tele2.net/upload/TEST.TXT"); 34 //rs = rq.post("ftp://speedtest.tele2.net/upload/TEST.TXT", "test, ignore please\n".representation); 35 //assert(unreliable_network || rs.code == 226); 36 //info("ftp get ", "ftp://speedtest.tele2.net/nonexistent", ", in same session."); 37 //rs = rq.get("ftp://speedtest.tele2.net/nonexistent"); 38 //assert(unreliable_network || rs.code != 226); 39 //rq.useStreaming = false; 40 //info("ftp get ", "ftp://speedtest.tele2.net/1KB.zip", ", in same session."); 41 //rs = rq.get("ftp://speedtest.tele2.net/1KB.zip"); 42 //assert(unreliable_network || rs.code == 226); 43 //assert(unreliable_network || rs.responseBody.length == 1024); 44 //info("ftp post ", "ftp://speedtest.tele2.net/upload/TEST.TXT"); 45 //rs = rq.post("ftp://speedtest.tele2.net/upload/TEST.TXT", "another test, ignore please\n".representation); 46 //assert(unreliable_network || rs.code == 226); 47 //info("ftp get ", "ftp://ftp.iij.ad.jp/pub/FreeBSD/README.TXT"); 48 //try { 49 // rs = rq.get("ftp://ftp.iij.ad.jp/pub/FreeBSD/README.TXT"); 50 //} catch (ConnectError e) 51 //{ 52 //} 53 //assert(unreliable_network || rs.code == 226); 54 //rq.authenticator = new BasicAuthentication("anonymous", "request@"); 55 //try { 56 // rs = rq.get("ftp://ftp.iij.ad.jp/pub/FreeBSD/README.TXT"); 57 //} catch (ConnectError e) 58 //{ 59 //} 60 //assert(unreliable_network || rs.code == 226); 61 //info("testing ftp - done.");
Call post and return response content.