Registry / http-networking / messy
library0.0.0jsnpmunverified

messy is a JavaScript library providing a robust object model for parsing, manipulating, and serializing HTTP messages (requests and responses) and RFC822 (email) messages. It aims to simplify interaction with these complex message formats by abstracting header parsing, body handling, and common operations into a coherent API. The current stable version, 7.0.0, was released in November 2020. Given the last release date, the package is likely in a maintenance state, indicating stability rather than active feature development. It differentiates itself by offering a unified approach to both HTTP and email message structures, which often share similar header-based formats, making it suitable for applications requiring deep inspection or modification of network and mail protocols.

npm install messy
INSTALL
IMPORT
SIG · MESSY
M
messy
http-networkingjavascriptv0.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpRequest
import { HttpRequest } from 'messy'
const HttpRequest = require('messy').HttpRequest
ESM is the preferred import style since Node.js module support matured; CommonJS `require` is also typically supported for older Node.js environments.
HttpResponse
import { HttpResponse } from 'messy'
const HttpResponse = require('messy').HttpResponse
For server-side applications, `HttpResponse` facilitates creating and manipulating HTTP server responses programmatically.
Rfc822Message
import { Rfc822Message } from 'messy'
const Rfc822Message = require('messy').Rfc822Message
`Rfc822Message` is used for email message parsing and construction, adhering to RFC822/RFC2822 standards.

This quickstart demonstrates creating HTTP request and RFC822 email message objects, setting headers, and parsing a raw HTTP response string to extract its status, headers, and body. It showcases the core functionalities of the `messy` library.

import { HttpRequest, HttpResponse, Rfc822Message } from 'messy'; // Example 1: Create and manipulate an HTTP Request const httpRequest = new HttpRequest({ method: 'GET', url: '/api/users?id=123', headers: { 'Host': 'example.com', 'Accept': 'application/json', 'User-Agent': 'MessyClient/1.0' } }); httpRequest.setHeader('Authorization', 'Bearer token123'); console.log(`HTTP Request Method: ${httpRequest.method}`); console.log(`HTTP Request URL: ${httpRequest.url}`); console.log(`HTTP Request Auth Header: ${httpRequest.getHeader('Authorization')}`); // Example 2: Parse a raw HTTP Response string const rawHttpResponse = [ 'HTTP/1.1 200 OK', 'Content-Type: application/json', 'Content-Length: 28', '', '{"message": "Hello, World!"}' ].join('\r\n'); const httpResponse = HttpResponse.parse(rawHttpResponse); console.log(`HTTP Response Status Code: ${httpResponse.statusCode}`); console.log(`HTTP Response Content-Type: ${httpResponse.getHeader('Content-Type')}`); httpResponse.body.then(bodyBuffer => { console.log(`HTTP Response Body: ${bodyBuffer.toString('utf-8')}`); }); // Example 3: Create an RFC822 (Email) Message const emailMessage = new Rfc822Message({ headers: { 'From': 'sender@example.com', 'To': 'recipient@example.com', 'Subject': 'Hello from Messy!', 'Content-Type': 'text/plain; charset="utf-8"' }, body: 'This is the plain text body of the email.' }); console.log(`Email Subject: ${emailMessage.getHeader('Subject')}`); emailMessage.body.then(bodyBuffer => { console.log(`Email Body: ${bodyBuffer.toString('utf-8')}`); });
Debug
Known issues
gotchaThe `messy` package, version 7.0.0, was last published in November 2020. While stable for its defined purpose, this means it may not receive active feature updates or rapid bug fixes. Users should evaluate its suitability for projects requiring modern protocol features or very active maintenance.
fix
Consider checking the GitHub repository for recent activity or forks if active development is a strict requirement for your project.
affects: >=7.0.0
breakingAs a major version release, `messy` v7.0.0 likely introduced breaking changes from previous 6.x versions, common in JavaScript libraries of that era. These often include API cleanups, removal of deprecated methods, or adjustments for newer Node.js versions or JavaScript features. Specific details require consulting the changelog, which is not provided in the prompt.
fix
Thoroughly review the package's changelog or migration guide for version 7.x, if available on its GitHub repository, before upgrading from 6.x. Test existing codebases extensively after upgrading.
affects: >=7.0.0 <8.0.0
gotchaHeader names in HTTP and RFC822 messages are case-insensitive, but when interacting with `messy`'s API (e.g., `setHeader`, `getHeader`), consistent casing (e.g., 'Content-Type' vs 'content-type') is crucial for predictable behavior, even if the underlying parsing normalizes it. Inconsistencies can lead to missed headers or unexpected results.
fix
Always use a canonical casing (e.g., 'Title-Case') for header names when programmatically accessing or modifying them, or use helper functions if the library provides case-insensitive accessors.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'headers')
Attempting to create a message object (e.g., HttpRequest, Rfc822Message) without providing the required `headers` property in the constructor options object.
fix
Ensure the constructor is called with an object containing at least an empty `headers` property: `new HttpRequest({ headers: {} })`.
Error: Invalid message format: Missing required header components
Parsing a malformed or incomplete raw message string using `HttpRequest.parse()` or `HttpResponse.parse()`. This error typically indicates fundamental structural issues like missing the status line or a malformed header section.
fix
Validate the input raw message string against HTTP/RFC822 specifications before attempting to parse it. Ensure it has at least a valid start line (e.g., `HTTP/1.1 200 OK`) and a correctly delimited header section.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
messy — npm install messy · libregistry