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

x/ayonli_jsext/http/util.ts>parseResponse

A JavaScript extension package for building strong and modern applications.
Latest
function parseResponse
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

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!"

Parameters

message: string