Buffer!ubyte which you can use as ForwardRange or DirectAccessRange, or extract data with .data() method.
import std.algorithm; import std.stdio; import std.json; globalLogLevel(LogLevel.info); info("Test getContent"); auto r = getContent("https://httpbin.org/stream/20"); assert(r.splitter('\n').filter!("a.length>0").count == 20); r = getContent("ftp://speedtest.tele2.net/1KB.zip"); assert(r.length == 1024); r = getContent("https://httpbin.org/get", ["a":"b", "c":"d"]); string name = "user", sex = "male"; int age = 42; r = getContent("https://httpbin.org/get", "name", name, "age", age, "sex", sex);
globalLogLevel(LogLevel.info); info("Test get in parallel"); import std.stdio; import std.parallelism; import std.algorithm; import std.string; import core.atomic; immutable auto urls = [ "http://httpbin.org/stream/10", "https://httpbin.org/stream/20", "http://httpbin.org/stream/30", "https://httpbin.org/stream/40", "http://httpbin.org/stream/50", "https://httpbin.org/stream/60", "http://httpbin.org/stream/70", ]; defaultPoolThreads(5); shared short lines; foreach(url; parallel(urls)) { atomicOp!"+="(lines, getContent(url).splitter("\n").count); } assert(lines == 287);
Call GET, and return response content. args = variadic args to supply parameter names and values.