Skip to main content
Deno 2 is finally here 🎉️
Learn more

picohttpparser in Deno

import { parseRequest } from "https://deno.land/x/picohttpparser/mod.ts";

let h0 = encode(`HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\nHello, World!`);
let req = parseRequest(h0);

while (req.isPartial) {
  // Read more bytes from _somewhere_
  h0 = read();
  req = parseRequest(h0);
}

req.method; // "GET"
req.url; // "/"
req.body; // null

image