reqwest v0.9.0 Release Notes

  • ๐Ÿ”‹ Features

    • โฌ†๏ธ Upgrade to tokio 0.1.
    • โฌ†๏ธ Upgrade to hyper 0.12.
    • โฌ†๏ธ Upgrade to native-tls 0.2.
    • Add ClientBuilder::danger_accept_invalid_certs(bool) to disable certificate verification.
    • โž• Add RequestBuilder::bearer_auth(token) to ease sending bearer tokens.
    • โž• Add headers() and headers_mut() to multipart::Part to allow sending extra headers for a specific part.
    • ๐Ÿšš Moved request::unstable::async to reqwest::async.

    ๐Ÿ›  Fixes

    • ๐Ÿ›  Fix panicking when passing a Url with a file:// scheme. Instead, an Error is returned.

    ๐Ÿ’ฅ Breaking Changes

    • Changed ClientBuilder::danger_disable_hostname_verification() to ClientBuilder::danger_accept_invalid_hostnames(bool).
    • ๐Ÿ”„ Changed ClientBuilder to be a by-value builder instead of by-ref.

    For single chains of method calls, this shouldn't affect you. For code that conditionally uses the builder, this kind of change is needed:

      // Old
      let mut builder = ClientBuilder::new();
      if some_val {
          builder.gzip(false);
      }
      let client = builder.build()?;
    
      // New
      let mut builder = ClientBuilder::new();
      if some_val {
          builder = builder.gzip(false);
      }
      let client = builder.build()?;
    
    • ๐Ÿ”„ Changed RequestBuilder to be a by-value builder of by-ref.

    See the previous note about ClientBuilder for affected code and how to change it.

    • โœ‚ Removed the unstable cargo-feature, and moved reqwest::unstable::async to reqwest::async.
    • ๐Ÿ”„ Changed multipart::Part::mime() to mime_str().
      // Old
      let part = multipart::Part::file(path)?
          .mime(mime::TEXT_PLAIN);
    
      // New
      let part = multipart::Part::file(path)?
          .mime_str("text/plain")?;
    
    • โฌ†๏ธ The upgrade to hyper 0.12 means a temporary removal of the typed headers.

    The RequestBuilder has simple methods to set headers using strings, which can work in most places.

      // Old
      client
          .get("https://hyper.rs")
          .header(UserAgent::new("hallo"))
          .send()?;
    
      // New
      client
          .get("https://hyper.rs")
          .header("user-agent", "hallo")
          .send()?;
    

    To ease the transition, there is a hyper-011 cargo-feature that can be enabled.

      [dependencies]
      reqwest = { version = "0.9", features = ["hyper-011"] }
    

    And then usage:

      client
          .get("https://hyper.rs")
          .header_011(reqwest::hyper_011::header::UserAgent::new("hallo"))
          .send()?;