Protocol::HTTP
Provides abstractions for working with the HTTP protocol.
Features
- General abstractions for HTTP requests and responses.
- Symmetrical interfaces for client and server.
- Light-weight middleware model for building applications.
Usage
Please browse the source code index or refer to the guides below.
Getting Started
This guide explains how to use protocol-http for building abstract HTTP interfaces.
Message Body
This guide explains how to work with HTTP request and response message bodies using Protocol::HTTP::Body classes.
Headers
This guide explains how to work with HTTP headers using protocol-http.
Middleware
This guide explains how to build and use HTTP middleware with Protocol::HTTP::Middleware.
Hypertext References
This guide explains how to use Protocol::HTTP::Reference for constructing and manipulating hypertext references (URLs with parameters).
URL Parsing
This guide explains how to use Protocol::HTTP::URL for parsing and manipulating URL components, particularly query strings and parameters.
Streaming
This guide gives an overview of how to implement streaming requests and responses.
Design Overview
This guide explains the high level design of protocol-http in the context of wider design patterns that can be used to implement HTTP clients and servers.
Releases
Please browse the releases for more details.
v0.54.0
- Introduce rich support for
Header::Digest,Header::ServerTiming,Header::TE,Header::TrailerandHeader::TransferEncoding.
v0.53.0
- Improve consistency of Body
#inspect. - Improve
as_jsonsupport for Body wrappers.
v0.52.0
- Add
Protocol::HTTP::Headers#to_amethod that returns the fields array, providing compatibility with standard Ruby array conversion pattern. - Expose
tailinHeaders.newso that trailers can be accurately reproduced. - Add agent context.
v0.51.0
Protocol::HTTP::Headersnow raise aDuplicateHeaderErrorwhen a duplicate singleton header (e.g.content-length) is added.Protocol::HTTP::Headers#addnow coerces the value to a string when adding a header, ensuring consistent behaviour.Protocol::HTTP::Body::Head.fornow accepts an optionallengthparameter, allowing it to create a head body even when the body is not provided, based on the known content length.
v0.50.0
- Drop support for Ruby v3.1.
v0.48.0
- Add support for parsing
accept,accept-charset,accept-encodingandaccept-languageheaders into structured values.
v0.46.0
- Add support for
priority:header.
v0.33.0
- Clarify behaviour of streaming bodies and copy
Protocol::Rack::Body::StreamingtoProtocol::HTTP::Body::Streamable. - Copy
Async::HTTP::Body::WritabletoProtocol::HTTP::Body::Writable.
v0.31.0
- Ensure chunks are flushed if required, when streaming.
v0.30.0
See Also
- protocol-http1 — HTTP/1 client/server implementation using this interface.
- protocol-http2 — HTTP/2 client/server implementation using this interface.
- async-http — Asynchronous HTTP client and server, supporting multiple HTTP protocols & TLS.
- async-websocket — Asynchronous client and server WebSockets.
Contributing
We welcome contributions to this project.
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature). - Commit your changes (
git commit -am 'Add some feature'). - Push to the branch (
git push origin my-new-feature). - Create new Pull Request.
Developer Certificate of Origin
In order to protect users of this project, we require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.
Community Guidelines
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.