import { parseResponse } from "https://deno.land/x/ayonli_jsext@v0.9.72/http/util.ts";
Parses the text message as an HTTP response.
Examples
Example 1
Example 1
import { parseResponse } from "@ayonli/jsext/http";
const message = "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/plain\r\n"
+ "Content-Length: 12\r\n"
+ "\r\n"
+ "Hello, World!";
const res = parseResponse(message);
console.log(res.status); // 200
console.log(res.statusText); // "OK"
console.log(res.headers.get("Content-Type")); // "text/plain"
const text = await res.text();
console.log(text); // "Hello, World!"