Skip to content

Releases: http-rs/http-types

v2.3.0

11 Jul 22:43
@jbr jbr
dd19cf0
Compare
Choose a tag to compare

This release one bug and adds several non-breaking enhancements.

Bugfix:

  • #189 adds std::marker::Sync to the return type of Body::into_reader

Enhancements:

  • #188 Adds as_str to http_types::mime::ParamName and http_types::mime::ParamValue
  • #194 Adds http dav extension status code 207
  • #196 Adds an XML mime constant and matches the .xml file extension to it
  • #197 Adds a public Mime::from_extension, exposing file extension matching outside of the http-types
  • #199 Adds Body::mime() and Body::set_mime(), allowing external crates to set a custom mime type on a body

Internal:

  • #178 http-types now conforms to clippy lints and CI runs clippy by default

v2.2.1

21 Jun 17:42
Compare
Choose a tag to compare

This patch fixes several bugs.

Fixes

  • Used serde_qs for querystrings #182
  • Fixed trailers method signature #176

v2.2.0

05 Jun 16:06
0f73eb9
Compare
Choose a tag to compare

Docs

This patch introduces a new experimental trace submodule and improves the Debug output for headers.

Trace submodule

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.

Better Debug output for Headers

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,
}

Added

  • Add trace submodule as "unstable" #172

Changed

  • update cookie to 0.14 #170
  • Implement Debug for Headers and related structs #173

Internal

  • Add CI job for wasm32-unknown-unknown #166

v2.1.0

29 May 13:57
Compare
Choose a tag to compare

Docs

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.

Example

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)?;

Added

  • Added method shorthands for Request constructor #159
  • Status takes TryInto<StatusCode> #157
  • Added feature for enabling signed and encrypted cookie support #152 #165
  • Added the upgrade submodule as "unstable" #115

Fixes

  • Made Request::query behavior consistent with Tide #162
  • Fixed links to the CONTRIBUTING page from the README #158
  • Body parse errors return status 422 #163
  • Fixed compilation on wasm32-unknown-unknown #153

Internal

  • Define Mime constants using macros #160

v2.0.1

24 May 10:33
Compare
Choose a tag to compare

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.

Changed

  • Update dependencies #150

Fixed

  • Request and Response body_* methods now take &mut self rather than self #151

v2.0.0

22 May 22:03
Compare
Choose a tag to compare

Documentation

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.

Upgrade notes

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);

Added

  • Implement Clone for Request and Response #91
  • Added various From conversions for Body, Request, and Response #101 #100
  • Added logos to docs.rs #111
  • Added status codes 422, 423, 424, 507, 508 #112 #114
  • Added all header constants from RFC2616 #107
  • Added Request::{peer_addr, local_addr} and Request::{set_peer_addr, set_local_addr} #119
  • Implemented Index for Headers, enabling req["name"]-style lookup #110
  • Added Request::host and Request::remote #131 #119
  • Added mime sniffing to Body::from_file #132
  • Added Request::{set_query, query} #143

Changed

  • Reworked trailers to no longer return a Result and renamed the types in the submodule #103
  • We're now able to initialize mime constants with parameters, which means some constants now include utf-8 encoding #105
  • Replaced Vec<HeaderValue> with HeaderValues. This enabled more conversions and easier comparisons #109
  • Modified the MIME parser to 1:1 follow the WHATWG algorithm #122
  • Renamed TypeMap to Extensions #118
  • Header operations no longer return Result and consistently take TryFrom #127
  • Request and Response constructors now take arguments using TryFrom #127
  • The percent-encoding feature on the cookies dependency is now always enabled #134

Removed

  • Removed the cookie APIs from Request and Response #111

Internal

  • Ensure hyperium/http compat is tested on CI #130
  • Added Version ordering tests #135

v1.3.1

22 May 22:00
05722e2
Compare
Choose a tag to compare

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.

Changes

  • Updates async-std to 1.6.0 #148

v1.3.0

21 Apr 10:12
Compare
Choose a tag to compare

Added

  • Added Client and Server traits as "unstable" #94
  • Added a security submodule #98

Changed

  • Applied clippy throughout the codebase #92

v1.2.0

16 Apr 11:59
Compare
Choose a tag to compare

Added

  • add the HOST header to header constants #97
  • Implement TryFrom<&'a str> for HeaderValue and Method #95

v1.1.1

11 Apr 13:52
Compare
Choose a tag to compare

Fixed

  • Empty headers passing through the hyperium compat layer are now correctly handled #93