1*6236dae4SAndroid Build Coastguard Worker<!-- 2*6236dae4SAndroid Build Coastguard WorkerCopyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard Worker 4*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 5*6236dae4SAndroid Build Coastguard Worker--> 6*6236dae4SAndroid Build Coastguard Worker 7*6236dae4SAndroid Build Coastguard Worker# Hyper 8*6236dae4SAndroid Build Coastguard Worker 9*6236dae4SAndroid Build Coastguard WorkerHyper is a separate HTTP library written in Rust. curl can be told to use this 10*6236dae4SAndroid Build Coastguard Workerlibrary as a backend to deal with HTTP. 11*6236dae4SAndroid Build Coastguard Worker 12*6236dae4SAndroid Build Coastguard Worker## EXPERIMENTAL 13*6236dae4SAndroid Build Coastguard Worker 14*6236dae4SAndroid Build Coastguard WorkerHyper support in curl is considered **EXPERIMENTAL** until further notice. It 15*6236dae4SAndroid Build Coastguard Workerneeds to be explicitly enabled at build-time. 16*6236dae4SAndroid Build Coastguard Worker 17*6236dae4SAndroid Build Coastguard WorkerFurther development and tweaking of the Hyper backend support in curl happens 18*6236dae4SAndroid Build Coastguard Workerin the master branch using pull-requests, just like ordinary changes. 19*6236dae4SAndroid Build Coastguard Worker 20*6236dae4SAndroid Build Coastguard Worker## Hyper version 21*6236dae4SAndroid Build Coastguard Worker 22*6236dae4SAndroid Build Coastguard WorkerThe C API for Hyper is brand new and is still under development. 23*6236dae4SAndroid Build Coastguard Worker 24*6236dae4SAndroid Build Coastguard Worker## Build curl with hyper 25*6236dae4SAndroid Build Coastguard Worker 26*6236dae4SAndroid Build Coastguard WorkerUsing Rust 1.64.0 or later, build hyper and enable its C API like this: 27*6236dae4SAndroid Build Coastguard Worker 28*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/hyperium/hyper 29*6236dae4SAndroid Build Coastguard Worker % cd hyper 30*6236dae4SAndroid Build Coastguard Worker % RUSTFLAGS="--cfg hyper_unstable_ffi" cargo rustc --features client,http1,http2,ffi --crate-type cdylib 31*6236dae4SAndroid Build Coastguard Worker 32*6236dae4SAndroid Build Coastguard WorkerAlso, `--release` can be added for a release (optimized) build. 33*6236dae4SAndroid Build Coastguard Worker 34*6236dae4SAndroid Build Coastguard WorkerBuild curl to use hyper's C API: 35*6236dae4SAndroid Build Coastguard Worker 36*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 37*6236dae4SAndroid Build Coastguard Worker % cd curl 38*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 39*6236dae4SAndroid Build Coastguard Worker % ./configure LDFLAGS="-Wl,-rpath,<hyper-dir>/target/debug -Wl,-rpath,<hyper-dir>/target/release" --with-openssl --with-hyper=<hyper-dir> 40*6236dae4SAndroid Build Coastguard Worker % make 41*6236dae4SAndroid Build Coastguard Worker 42*6236dae4SAndroid Build Coastguard Worker# Using Hyper internally 43*6236dae4SAndroid Build Coastguard Worker 44*6236dae4SAndroid Build Coastguard WorkerHyper is a low level HTTP transport library. curl itself provides all HTTP 45*6236dae4SAndroid Build Coastguard Workerheaders and Hyper provides all received headers back to curl. 46*6236dae4SAndroid Build Coastguard Worker 47*6236dae4SAndroid Build Coastguard WorkerTherefore, most of the "header logic" in curl as in responding to and acting 48*6236dae4SAndroid Build Coastguard Workeron specific input and output headers are done the same way in curl code. 49*6236dae4SAndroid Build Coastguard Worker 50*6236dae4SAndroid Build Coastguard WorkerThe API in Hyper delivers received HTTP headers as (cleaned up) name=value 51*6236dae4SAndroid Build Coastguard Workerpairs, making it impossible for curl to know the exact byte representation 52*6236dae4SAndroid Build Coastguard Workerover the wire with Hyper. 53*6236dae4SAndroid Build Coastguard Worker 54*6236dae4SAndroid Build Coastguard Worker## Limitations 55*6236dae4SAndroid Build Coastguard Worker 56*6236dae4SAndroid Build Coastguard WorkerThe hyper backend does not support 57*6236dae4SAndroid Build Coastguard Worker 58*6236dae4SAndroid Build Coastguard Worker- `CURLOPT_IGNORE_CONTENT_LENGTH` 59*6236dae4SAndroid Build Coastguard Worker- `--raw` and disabling `CURLOPT_HTTP_TRANSFER_DECODING` 60*6236dae4SAndroid Build Coastguard Worker- RTSP 61*6236dae4SAndroid Build Coastguard Worker- hyper is much stricter about what HTTP header contents it allows 62*6236dae4SAndroid Build Coastguard Worker- leading whitespace in first HTTP/1 response header 63*6236dae4SAndroid Build Coastguard Worker- HTTP/0.9 64*6236dae4SAndroid Build Coastguard Worker- HTTP/2 upgrade using HTTP:// URLs. Aka 'h2c' 65*6236dae4SAndroid Build Coastguard Worker- HTTP/2 in general. Hyper has support for HTTP/2 but the curl side 66*6236dae4SAndroid Build Coastguard Worker needs changes so that a `hyper_clientconn` can last for the duration 67*6236dae4SAndroid Build Coastguard Worker of a connection. Probably this means turning the Hyper HTTP/2 backend 68*6236dae4SAndroid Build Coastguard Worker into a connection filter. 69*6236dae4SAndroid Build Coastguard Worker 70*6236dae4SAndroid Build Coastguard Worker## Remaining issues 71*6236dae4SAndroid Build Coastguard Worker 72*6236dae4SAndroid Build Coastguard WorkerThis backend is still not feature complete with the native backend. Areas that 73*6236dae4SAndroid Build Coastguard Workerstill need attention and verification include: 74*6236dae4SAndroid Build Coastguard Worker 75*6236dae4SAndroid Build Coastguard Worker- multiplexed HTTP/2 76*6236dae4SAndroid Build Coastguard Worker- h2 Upgrade: 77*6236dae4SAndroid Build Coastguard Worker- receiving HTTP/1 trailers 78*6236dae4SAndroid Build Coastguard Worker- sending HTTP/1 trailers 79