File: http2.rs

package info (click to toggle)
rust-isahc 1.7.2%2Bds-33
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,184 kB
  • sloc: makefile: 26; sh: 1
file content (16 lines) | stat: -rw-r--r-- 462 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! This example simply demonstrates HTTP/2 support by making a request that
//! enforces usage of HTTP/2.

use isahc::{config::VersionNegotiation, prelude::*, Request};

fn main() -> Result<(), isahc::Error> {
    let response = Request::get("https://nghttp2.org")
        .version_negotiation(VersionNegotiation::http2())
        .body(())
        .map_err(Into::into)
        .and_then(isahc::send)?;

    println!("{:#?}", response.headers());

    Ok(())
}