{"library":"messy","title":"HTTP and RFC822 Message Object Model","description":"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.","language":"javascript","status":"maintenance","last_verified":"Thu Apr 23","install":{"commands":["npm install messy"],"cli":null},"imports":["import { HttpRequest } from 'messy'","import { HttpResponse } from 'messy'","import { Rfc822Message } from 'messy'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { HttpRequest, HttpResponse, Rfc822Message } from 'messy';\n\n// Example 1: Create and manipulate an HTTP Request\nconst httpRequest = new HttpRequest({\n  method: 'GET',\n  url: '/api/users?id=123',\n  headers: {\n    'Host': 'example.com',\n    'Accept': 'application/json',\n    'User-Agent': 'MessyClient/1.0'\n  }\n});\n\nhttpRequest.setHeader('Authorization', 'Bearer token123');\nconsole.log(`HTTP Request Method: ${httpRequest.method}`);\nconsole.log(`HTTP Request URL: ${httpRequest.url}`);\nconsole.log(`HTTP Request Auth Header: ${httpRequest.getHeader('Authorization')}`);\n\n// Example 2: Parse a raw HTTP Response string\nconst rawHttpResponse = [\n  'HTTP/1.1 200 OK',\n  'Content-Type: application/json',\n  'Content-Length: 28',\n  '',\n  '{\"message\": \"Hello, World!\"}'\n].join('\\r\\n');\n\nconst httpResponse = HttpResponse.parse(rawHttpResponse);\nconsole.log(`HTTP Response Status Code: ${httpResponse.statusCode}`);\nconsole.log(`HTTP Response Content-Type: ${httpResponse.getHeader('Content-Type')}`);\nhttpResponse.body.then(bodyBuffer => {\n  console.log(`HTTP Response Body: ${bodyBuffer.toString('utf-8')}`);\n});\n\n// Example 3: Create an RFC822 (Email) Message\nconst emailMessage = new Rfc822Message({\n  headers: {\n    'From': 'sender@example.com',\n    'To': 'recipient@example.com',\n    'Subject': 'Hello from Messy!',\n    'Content-Type': 'text/plain; charset=\"utf-8\"'\n  },\n  body: 'This is the plain text body of the email.'\n});\n\nconsole.log(`Email Subject: ${emailMessage.getHeader('Subject')}`);\nemailMessage.body.then(bodyBuffer => {\n  console.log(`Email Body: ${bodyBuffer.toString('utf-8')}`);\n});\n","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}