113498266Sopenharmony_ci# Hyper
213498266Sopenharmony_ci
313498266Sopenharmony_ciHyper is a separate HTTP library written in Rust. curl can be told to use this
413498266Sopenharmony_cilibrary as a backend to deal with HTTP.
513498266Sopenharmony_ci
613498266Sopenharmony_ci## Experimental!
713498266Sopenharmony_ci
813498266Sopenharmony_ciHyper support in curl is considered **EXPERIMENTAL** until further notice. It
913498266Sopenharmony_cineeds to be explicitly enabled at build-time.
1013498266Sopenharmony_ci
1113498266Sopenharmony_ciFurther development and tweaking of the Hyper backend support in curl will
1213498266Sopenharmony_cihappen in the master branch using pull-requests, just like ordinary
1313498266Sopenharmony_cichanges.
1413498266Sopenharmony_ci
1513498266Sopenharmony_ci## Hyper version
1613498266Sopenharmony_ci
1713498266Sopenharmony_ciThe C API for Hyper is brand new and is still under development.
1813498266Sopenharmony_ci
1913498266Sopenharmony_ci## build curl with hyper
2013498266Sopenharmony_ci
2113498266Sopenharmony_ciUsing Rust 1.64.0 or later, build hyper and enable its C API like this:
2213498266Sopenharmony_ci
2313498266Sopenharmony_ci     % git clone https://github.com/hyperium/hyper
2413498266Sopenharmony_ci     % cd hyper
2513498266Sopenharmony_ci     % RUSTFLAGS="--cfg hyper_unstable_ffi" cargo rustc --features client,http1,http2,ffi --crate-type cdylib
2613498266Sopenharmony_ci
2713498266Sopenharmony_ciAlso, `--release` can be added for a release (optimized) build.
2813498266Sopenharmony_ci
2913498266Sopenharmony_ciBuild curl to use hyper's C API:
3013498266Sopenharmony_ci
3113498266Sopenharmony_ci     % git clone https://github.com/curl/curl
3213498266Sopenharmony_ci     % cd curl
3313498266Sopenharmony_ci     % autoreconf -fi
3413498266Sopenharmony_ci     % ./configure LDFLAGS="-Wl,-rpath,<hyper-dir>/target/debug -Wl,-rpath,<hyper-dir>/target/release" --with-openssl --with-hyper=<hyper-dir>
3513498266Sopenharmony_ci     % make
3613498266Sopenharmony_ci
3713498266Sopenharmony_ci# using Hyper internally
3813498266Sopenharmony_ci
3913498266Sopenharmony_ciHyper is a low level HTTP transport library. curl itself provides all HTTP
4013498266Sopenharmony_ciheaders and Hyper provides all received headers back to curl.
4113498266Sopenharmony_ci
4213498266Sopenharmony_ciTherefore, most of the "header logic" in curl as in responding to and acting
4313498266Sopenharmony_cion specific input and output headers are done the same way in curl code.
4413498266Sopenharmony_ci
4513498266Sopenharmony_ciThe API in Hyper delivers received HTTP headers as (cleaned up) name=value
4613498266Sopenharmony_cipairs, making it impossible for curl to know the exact byte representation
4713498266Sopenharmony_ciover the wire with Hyper.
4813498266Sopenharmony_ci
4913498266Sopenharmony_ci## Limitations
5013498266Sopenharmony_ci
5113498266Sopenharmony_ciThe hyper backend does not support
5213498266Sopenharmony_ci
5313498266Sopenharmony_ci- `CURLOPT_IGNORE_CONTENT_LENGTH`
5413498266Sopenharmony_ci- `--raw` and disabling `CURLOPT_HTTP_TRANSFER_DECODING`
5513498266Sopenharmony_ci- RTSP
5613498266Sopenharmony_ci- hyper is much stricter about what HTTP header contents it allows
5713498266Sopenharmony_ci- leading whitespace in first HTTP/1 response header
5813498266Sopenharmony_ci- HTTP/0.9
5913498266Sopenharmony_ci- HTTP/2 upgrade using HTTP:// URLs. Aka 'h2c'
6013498266Sopenharmony_ci- HTTP/2 in general. Hyper has support for HTTP/2 but the curl side
6113498266Sopenharmony_ci  needs changes so that a `hyper_clientconn` can last for the duration
6213498266Sopenharmony_ci  of a connection. Probably this means turning the Hyper HTTP/2 backend
6313498266Sopenharmony_ci  into a connection filter.
6413498266Sopenharmony_ci
6513498266Sopenharmony_ci## Remaining issues
6613498266Sopenharmony_ci
6713498266Sopenharmony_ciThis backend is still not feature complete with the native backend. Areas that
6813498266Sopenharmony_cistill need attention and verification include:
6913498266Sopenharmony_ci
7013498266Sopenharmony_ci- multiplexed HTTP/2
7113498266Sopenharmony_ci- h2 Upgrade:
7213498266Sopenharmony_ci- receiving HTTP/1 trailers
7313498266Sopenharmony_ci- sending HTTP/1 trailers
74