http_parser
4.1.2, released 2 years ago by dart.dev
A platform-independent package for parsing and serializing HTTP formats.
What it does
It provides tools to parse and format HTTP dates, media types (like Accept and Content-Type headers), and other HTTP-related formats. It avoids referencing dart:io or dart:html so it can run on both browser and server.
AI-written summary of version 4.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to parse or serialize HTTP header values like Content-Type or media types.
- You are writing a cross-platform web and server application that needs to handle HTTP formats without depending on dart:io.
Skip it when
- You are looking for a full HTTP client library to make network requests.
- You need WebSocket channel implementations (which have been moved to web_socket_channel).
Strengths
- Platform-independent, works on both browser and server.
- Reliable parsing and formatting for standard HTTP formats and media types.
Weaknesses
- Limited in scope, strictly handles HTTP parsing and serialization formats rather than networking requests.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:http_parser/http_parser.dart';
void main() {
var mediaType = MediaType.parse('text/plain; charset=utf-8');
print(mediaType.type); // text
print(mediaType.subtype); // plain
print(mediaType.parameters['charset']); // utf-8
}Alternatives
Packages that do the same job and could replace http_parser.
- pretty_http_logger
Middleware logger for Dart's http package that prints requests and responses in a readable format.
53Compare - http_client
Platform‑independent HTTP client for browser, console and curl with SOCKS proxy support
50Compare - graphql_2_rest
Converts GraphQL queries into REST-compatible POST bodies for any HTTP client.
50Compare - sync_http
Synchronous HTTP client for Dart using RawSynchronousSockets.
50Compare
Works with
Packages commonly used together with http_parser: ones it builds on, ones built on it, and its own family.
- source_spanhttp_parser depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- string_scannerhttp_parser depends on itA class for parsing strings using a sequence of patterns.
- typed_datahttp_parser depends on itUtility functions and classes for easier work with dart:typed_data lists.
- built_valueSame familyImmutable value types with builders, enum classes and JSON serialization for Dart.
- asyncSame familyUtility classes and helpers that extend Dart's async library.
- hooksSame familyDart API for the JSON-based protocol for package build and link hooks.
- code_assetsSame familyProvides the hook protocol specification for bundling native code with Dart packages.
- testSame familyA full featured library for writing and running Dart tests across platforms.