NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #1376 most downloaded on crates.io
Common types for HTTP operations.
Latest stable
2.12.0
Last release 5 years ago
no release in 18 months
Release timing varies
gaps range from 2 weeks to 3 months
Most releases are documented
notes for 19 of 22 stable releases
1 version withdrawn
withdrawn after publishing
7 years old
23 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
More TryFrom<> conversions for the "hyperium_http" feature.
AsRef<anyhow::Error> for http_types::ErrorFrom<Vec<HeaderValue>> for HeaderValuesTryFrom<> conversions for the "hyperium_http" feature.*http-types provides shared types for HTTP operations. It combines a performant, streaming interface with convenient methods for creating headers, url
http-types provides shared types for HTTP operations. It combines a performant, streaming interface with convenient methods for creating headers, urls, and other standard HTTP types. This is part of the http-rs project and powers the tide framework and surf client. Check out the docs or join us on Zulip.
This release fixes an unconditional panic in the hyperium_http compatibility feature.
The http-types 3.0 merge window remains open, and you can see the nominated items for the next major version as part of the Semver-Major issue on GitHub.
hyperium_http: Avoids unconditional panic when translating headers from hyperium. #359Your coding agent can read these notes before it upgrades. Set up the MCP server →
This is a looser restriction and is not a breaking change. See serde's documentation on the subject.
http-types provides shared types for HTTP operations. It combines a performant, streaming interface with convenient methods for creating headers, urls, and other standard HTTP types. This is part of the http-rs project and powers the tide framework and surf client. Check out the docs or join us on Zulip.
This release represents continued support of the http-types 2.x release line due to delays in the development of http-types 3.0.0. This release comes with several convenience features, listed below.
The http-types 3.0 merge window remains open, and you can see the nominated items for the next major version as part of the Semver-Major issue on GitHub.
Request.query() to deserialize into a borrowed Deserialize<'de> rather than just DeserializeOwned. #333
Body::chain() for merge multiple Body instances. #342, #346AsRef<str> for Version, returning 'static str. #351Error::from_debug(), a helper for converting from std::error::Errors. #345Error::from_display, a helper for converting from std::error::Errors. #345Content-Encoding and Transfer-Encoding. #354url's crate new TryFrom<&str>. #324Content-Encoding and Transfer-Encoding docs. #354_http-types provides shared types for HTTP operations. It combines a performant, streaming interface with convenient methods for creating headers, url
http-types provides shared types for HTTP operations. It combines a performant, streaming interface with convenient methods for creating headers, urls, and other standard HTTP types. This is part of the http-rs project and powers the tide and surf frameworks. Check out the docs or join us on Zulip.
This release introduces several new typed headers:
transfer::TransferEncoding: The form of encoding used to safely transfer the payload body to the user.transfer::TE: Client header advertising the transfer encodings the user agent is willing to accept.other::RetryAfter: Indicate how long the user agent should wait before making a follow-up request.other::Referer: Contains the address of the page making the request.content::Accept: Client header advertising which media types the client is able to understand.content::ContentType: Indicate the media type of a resource's content.Most notably is probably the RetryAfter header, which can be used to enable load-shedding on the client. An example of such a middleware has been authored for Tide.
This marks the final release of the 2.x release line of http-types. It's been almost a year since our last major release, and we've decided to open up the merge window for http-types 3.0 now that 2.10.0 has shipped. You can see the nominated items for the next major version as part of the Semver-Major issue on GitHub.
Because this is the first major release of http-types we're doing since we moved to our monthly release cadence, we're not entirely sure yet how we'll manage this. Perhaps next month's release may be a beta release. Or we may delay doing a release at all until all items have been merged. We'll have to see, but once 3.0 is out we'll resume the monthly release cadence.
Retry-After type header #314"cookies" feature #306Transfer-Encoding and TE headers #301other::SourceMap header #278other::Referer header #277content::{Accept, ContentType} headers #270TryFrom<str> for Url implementation #294Stabilize support for protocol upgrades on Response #291
This patch adds support for cache::ClearSiteData, content::ContentLocation and implements ToHeaderValues for more string types. This continues our pro
This patch adds support for cache::ClearSiteData, content::ContentLocation and implements ToHeaderValues for more string types. This continues our progress on implementing typed headers. We're currently at 50/70 implemented, and expect to be finishing up in the near future. At which point we can start to integrate these into higher-level crates such as tide and surf.
ToHeaderValues for more string types #279cache::ClearSiteData header #265content::ContentLocation header #256, #276This patch adds support for auth typed headers, enables our enums to be serialized and deserialized through serde, and fixes a bug in our Method strin
This patch adds support for auth typed headers, enables our enums to be serialized and deserialized through serde, and fixes a bug in our Method string parser.
This patch introduces type-safe headers for authentication. The core headers are auth::{Authorization, AuthenticationScheme, WwwAuthenticate} which enable a server to request a client to authenticate, and for the client to construct authentication. However for convenience we've added support for the BasicAuth authentication scheme, making it straight forward to add some authentication to your application.
The plan for typed headers is to enable higher-level middleware to be written for them. As you can see in the example below, while application authors no longer need to deal with correctly parsing and encoding headers it's not exactly convenient yet. We're currently about halfway through implementing encoders and parsers for all known typed headers. And once that's complete it'll enable us to iterate on convenient features and middleware in the tide and surf frameworks.
However for now, here's a simplified example of how to use the new BasicAuth typed headers with the tide server:
use tide::http::auth::{AuthenticationScheme, BasicAuth, WwwAuthenticate};
use tide::http::ensure_eq;
use tide::sessions::{MemoryStore, SessionMiddleware};
use tide::{Request, Response};
// Global variables for the example; don't do this in a production setting
const SECRET: &[u8] = b"shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh";
const USERNAME: &str = "nori";
const PASSWORD: &str = "ilovefish";
const USER_ID: &str = "12";
// Setup a Tide app with a single endpoint that requires authentication
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
tide::log::start();
let mut app = tide::new();
app.with(SessionMiddleware::new(MemoryStore::new(), SECRET));
app.at("/").get(login);
app.listen("127.0.0.1:8080").await?;
Ok(())
}
// An endpoint that validates the credentials on a request
// and marks a session as authenticated if they pass
async fn login(mut req: Request<()>) -> tide::Result {
let session = req.session();
// Check if we're already logged in
if let Some(_) = session.get::<String>("user_id") {
return Ok("Already logged in!".into());
}
// Check if credentials are passed; if not request them.
let auth = match BasicAuth::from_headers(&req)? {
Some(auth) => auth,
None => {
let schema = AuthenticationScheme::Basic;
let realm = "access the tuna mainframe";
let auth = WwwAuthenticate::new(schema, realm.into());
return Ok(Response::builder(401)
.header(auth.name(), auth.value())
.build());
}
};
// Validate the username and password. In a real application we'd
// validate the hashed password from a database. This is an example only.
ensure_eq!(auth.username(), USERNAME, "unknown username");
ensure_eq!(auth.password(), PASSWORD, "incorrect password");
// If validation succeeded, mark the session as validated.
let session = req.session_mut();
session.insert("user_id", USER_ID)?;
// Print a success message
Ok("Login successful!".into())
}
serde::Deserialize and serde::Serialize impls for Version, StatusCode and Method #262auth::Authorization #252auth::AuthenticationScheme #252auth::BasicAuth #252auth::WwwAuthenticate #252auth::ProxyAuthorization #252auth::ProxyAuthenticate #252Method::parse case insensitive #261This patch introduces various new typed headers, and a feature flag to disable the async-std dependency.
This patch introduces various new typed headers, and a feature flag to disable the async-std dependency.
other::Date header #255server::Allow #254content::ContentLength #253async-std to enable people to disable the dependency #246This patch introduces various typed headers for content-negotiation, proxying, and makes it easier to work with statuscodes in errors.
This patch introduces various typed headers for content-negotiation, proxying, and makes it easier to work with statuscodes in errors.
contains to HeaderValues. #240content::AcceptEncoding. #232conditional::Vary #225conditional::{IfMatch, IfNoneMatch} #224conditional::{IfModifiedSince, IfUnmodifiedSince, LastModified} #222proxies::Forwarded header #221cache::Expires #220cache::Age header #219Error::type_name #213Error::set_status to take TryInto<StatusCode> #249Error::new to take TryInto<StatusCode> #216main #226TimingAllowOrigin to security submodule #217This patch introduces various unstable trace typed headers, adds a From<&str> impl for Mime, and includes a minor performance improvement.
This patch introduces various unstable trace typed headers, adds a From<&str> impl for Mime, and includes a minor performance improvement.
trace::ServerTiming as "unstable" #203From<&str> for Mime #179trace::AllowOrigin as "unstable" #209This release one bug and adds several non-breaking enhancements.
This release one bug and adds several non-breaking enhancements.
as_str to http_types::mime::ParamName and http_types::mime::ParamValueUsed serde_qs for querystrings #182
This patch fixes several bugs.
serde_qs for querystrings #182This patch introduces a new experimental trace submodule and improves the Debug output for headers.
This patch introduces a new experimental trace submodule and improves the Debug output for headers.
Tracking requests as they flow through services is a useful capability. To that extent the W3C has drafted a specification for standardized headers to "trace" requests through layers of servers. The trace submodule now contains a TraceContext object that has the logic required to parse, encode, and correlate requests with each other.
In the future we hope to be able to provide integrations in tide and turf so that when you create a request from a tide endpoint using surf, the two can automatically be correlated.
Printing Headers used to show various internal structures and hierarchies. Thanks to @jreyes33 the debug output of headers has become much easier to parse:
[src/request.rs:992] &request = Request {
method: Get,
url: "http://async.rs/",
headers: {
"single": "foo0",
"multi": [
"foo1",
"foo2",
],
},
version: None,
}
trace submodule as "unstable" #172This patch makes it easier to construct new requests, added more flexible bounds for the Status trait, and enabled secure cookies support out of the b
This patch makes it easier to construct new requests, added more flexible bounds for the Status trait, and enabled secure cookies support out of the box. Additionally we're now experimenting with a new upgrade submodule that will enable us to upgrade connections to e.g. websockets in a generic fashion.
Creating new requests is now easier:
let req = Request::get(Url::parse("https://soup.onion").unwrap());
In the future this will become even easier once the patch introducing TryFrom<&str> bounds for Url are released. This will remove the need to call Url::parse(...).unwrap() and will allow passing string literals to Request.
The Status trait is now more flexible as well:
let buf = fs::read("./my-file").await.status(StatusCode::NotFound)?;
// This patch now allows doing this as well.
let buf = fs::read("./my-file").await.status(404)?;
TryInto<StatusCode> #157upgrade submodule as "unstable" https://github.com/http-rs/http-types/pull/115Request::query behavior consistent with Tide #162Mime constants using macros https://github.com/http-rs/http-types/pull/160This patch updates an outdated dependency and fixes a bug that we found after releasing 2.0.0. Neither patch has required any changes in http-types' t
This patch updates an outdated dependency and fixes a bug that we found after releasing 2.0.0. Neither patch has required any changes in http-types' test suite or documentation, and we feel fairly confident most people won't need to change their code because of this patch.
Request and Response body_* methods now take &mut self rather than self https://github.com/http-rs/http-types/pull/151This patch makes it significantly easier to work with headers in http-types, introduces new status code constants, header constants, tweaks some APIs
This patch makes it significantly easier to work with headers in http-types, introduces new status code constants, header constants, tweaks some APIs we didn't get around the first time around.
Header types now include various PartialEq comparisons that weren't possible before. This makes it significantly easier to construct new headers, but also assert headers in tests:
// http-types 1.x
assert_eq!(req.header(&"X-Forwarded-For".parse().unwrap()), Some(&vec!["127.0.0.1".parse().unwrap()]));
// http-types 2.x
assert_eq!(req.header["X-Forwarded-For"], "127.0.0.1");
In addition many of our constructors now take TryInto values, which provides useful shorthands in places where unwrap was common. This should make it easier to construct both new Request and Response types.
This patch removes the Result type from the header* family of methods and the request/response constructors. In the past Result<Option<Value>> was returned to among other things catch ASCII conversion errors. This was usually handled simply by calling unwrap. However since APIs here now return Option instead of Result<Option>, unwrap will still be valid in code, but may unexpectedly panic. We recommend validating that header* methods are no longer being unwrapped.
let mut req = ...;
// The signature used to be `Result<Option<HeaderValue>>`
// and `unwrap` would cause a panic if `Err` was returned.
let val = req.header("my-header").unwrap();
// But now the signature is `Option<HeaderValue>` and
// `unwrap` will cause a panic if `None` is returned.
let val = req.header("my-header").unwrap();
// The solution is to remove additional `unwrap`s.
let val = req.header("my-header");
// However if you need to construct a header from user input,
// errors can be caught by constructing the header separately.
let name: HeaderName = "my-header".try_into().expect("invalid ascii");
let val = req.header(name);
Clone for Request and Response https://github.com/http-rs/http-types/pull/91From conversions for Body, Request, and Response https://github.com/http-rs/http-types/pull/101 https://github.com/http-rs/http-types/pull/100Request::{peer_addr, local_addr} and Request::{set_peer_addr, set_local_addr} https://github.com/http-rs/http-types/pull/119Index for Headers, enabling req["name"]-style lookup https://github.com/http-rs/http-types/pull/110Request::host and Request::remote https://github.com/http-rs/http-types/pull/131 https://github.com/http-rs/http-types/pull/119Body::from_file https://github.com/http-rs/http-types/pull/132Request::{set_query, query} https://github.com/http-rs/http-types/pull/143trailers to no longer return a Result and renamed the types in the submodule https://github.com/http-rs/http-types/pull/103Vec<HeaderValue> with HeaderValues. This enabled more conversions and easier comparisons https://github.com/http-rs/http-types/pull/109TypeMap to Extensions https://github.com/http-rs/http-types/pull/118Result and consistently take TryFrom https://github.com/http-rs/http-types/pull/127TryFrom https://github.com/http-rs/http-types/pull/127percent-encoding feature on the cookies dependency is now always enabled https://github.com/http-rs/http-types/pull/134hyperium/http compat is tested on CI https://github.com/http-rs/http-types/pull/130Version ordering tests https://github.com/http-rs/http-types/pull/135This patch fixes compatibility issues with async-std's "unstable" channel API introduced in async-std@1.6.0. This prevents people from running into is
This patch fixes compatibility issues with async-std's "unstable" channel API introduced in async-std@1.6.0. This prevents people from running into issues when performing fresh installs, or running cargo update.
async-std to 1.6.0 https://github.com/http-rs/http-types/pull/148add the HOST header to header constants https://github.com/http-rs/http-types/pull/97
Empty headers passing through the hyperium compat layer are now correctly handled #93
Add equality checks between headers and strings #80
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.