npm i http-moment
-
Send buffer except the last byte to the server
-
Ensure that all buffers are sent
-
Simultaneously send the last bytes of all requests
import { http, https } from "http-moment";
const { http, https } = require("http-moment");
const agent = new https.Agent();
agent.cork(5);
for (let i = 0; i < 5; ++i)
request("https://example.com", { agent }, console.log);
agent.cork(2);
request("https://example.com", { agent }, console.log);
request.post("https://example.com/hello", { agent, body: "hi" }, console.log);
cork(count: Number = 0): Promise
count
- if>= 1
, would uncork agent aftercount
requests
/* Usage example */
agent.cork();
agent.cork(0);
agent.cork(5); /* auto uncork after 5 requests */
uncork(): Promise
It's better to provide specific count
instead of manual use this method
/* Usage example */
agent.cork();
request("https://example.com", { agent }, console.log);
request("https://example.com/hello", { agent }, console.log);
// agent.uncork() - you can't use uncork immediately
setTimeout(() => agent.uncork(), 3000);
Released under MIT license