#http #http-client

yukikaze

Beautiful and elegant HTTP client library

17 releases

0.2.5 Sep 7, 2018
0.2.4 Sep 7, 2018
0.2.2 Aug 31, 2018
0.1.3 Aug 22, 2018
0.0.7 Aug 9, 2018

#27 in HTTP client

Download history 51/week @ 2018-08-19 78/week @ 2018-08-26 58/week @ 2018-09-02 92/week @ 2018-09-09 13/week @ 2018-09-16 32/week @ 2018-09-23 64/week @ 2018-09-30 16/week @ 2018-10-07 9/week @ 2018-10-14 302/week @ 2018-10-21 18/week @ 2018-10-28 85/week @ 2018-11-04 87/week @ 2018-11-11

131 downloads per month
Used in 2 crates

Apache-2.0

108KB
2K SLoC

雪風(Yukikaze)

Build Crates.io Documentation

Yukikaze image

Documentation

Beautiful and elegant Yukikaze is little HTTP client library based on hyper.

Available features

  • flate2-c - Enables decompression using flate2 crate with C backend. Default on.
  • flate2-rust - Enables decompression using flate2 crate with Rust backend. Default on.
  • encoding - Enables encoding crate support. Default off.
  • rt - Enables runtime module. Default off.

Features

  • Uses rustls for TLS
  • Support of various types of bodies: Plain text, JSON, multipart and forms
  • Simple redirect policy with option to limit number of redirections.
  • Support for encodings aside from UTF-8.
  • Various helpers to extract useful headers: Cookies, ETag/Last-Modified, Content related headers.
  • File redirection support for response's body.

Usage

In order to use Yukikaze-sama you need to create Client.

Configuration of of client can be defined using trait parameter Config. But default configuration in most cases reasonable for simple requests.

But if you need to work with client in generic context you can use its trait HttpClient.

Making request

Request builder provides rich set of methods to configure it, but in simple terms making request boils down to following code:

extern crate yukikaze;
extern crate tokio;

use yukikaze::client::{Client, HttpClient, Request};

fn main() {
    let mut tokio_rt = tokio::runtime::current_thread::Runtime::new().expect("To create runtime");
    let client = Client::default();

    let request = Request::get("http://127.0.0.1").expect("To create get request").empty();

    let response = client.execute(request); //Creates future response
    let response = tokio_rt.block_on(response); //Waits for response

    println!("response={:?}", response);
}

You can use rt module to simplify your workflow though.

Examples

  • fie - CLI shit posting tool for various social medias.

Q&A

Q: Why not just use reqwest/actix-web/mio_httpc?

A: Reqwest doesn't use rustls, actix-web client comes with lots of server code and mio_httpc is unknown beast to me(I just found out about it when created Yukikaze).


Q: I see some moon runes and anime picture. Are you one of these disgusting weebs?

A: Obviously yes ;)


Q: Why so many inlines? Are you this stupid to use pre-mature optimizations!?

A: Yes, I'm stupid enough because compiler doesn't want inline methods across crates by default(unless you turn on LTO)


Q: Why builder methods panic? Why don't you store error in builder and return it when finishing creating request?

A: I believe in normal cases you are not supposed to create invalid requests so I consider such errors as quite exceptional


Dependencies

~20MB
~537K SLoC