Agent API
Agent is low level interface for managing HTTP/1.1 Keep-Alive connection to the host.
It is the persist HTTP client to the same host and can be used as a connection pool. In most cases, fetch is enough for sending HTTP request but is useful to manage Keep-Alive connections.
import { createAgent } from "https://deno.land/x/[email protected]/mod.ts";
async function main() {
const agent = createAgent("https://servestjs.org");
const res1 = await agent.send({ method: "GET", path: "/@/server.ts" });
const res2 = await agent.send({ method: "GET", path: "/@/router.ts" });
console.log(res1);
console.log(res2);
}
main();