16dbb5987Sopenharmony_ci// Copyright (c) 2023 Huawei Device Co., Ltd. 26dbb5987Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 36dbb5987Sopenharmony_ci// you may not use this file except in compliance with the License. 46dbb5987Sopenharmony_ci// You may obtain a copy of the License at 56dbb5987Sopenharmony_ci// 66dbb5987Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 76dbb5987Sopenharmony_ci// 86dbb5987Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 96dbb5987Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 106dbb5987Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 116dbb5987Sopenharmony_ci// See the License for the specific language governing permissions and 126dbb5987Sopenharmony_ci// limitations under the License. 136dbb5987Sopenharmony_ci 146dbb5987Sopenharmony_ci//! `ylong_http_client` provides a HTTP client that based on `ylong_http` crate. 156dbb5987Sopenharmony_ci//! You can use the client to send request to a server, and then get the 166dbb5987Sopenharmony_ci//! response. 176dbb5987Sopenharmony_ci//! 186dbb5987Sopenharmony_ci//! # Supported HTTP Version 196dbb5987Sopenharmony_ci//! - HTTP/1.1 206dbb5987Sopenharmony_ci//! - HTTP/2 216dbb5987Sopenharmony_ci// TODO: Need doc. 226dbb5987Sopenharmony_ci 236dbb5987Sopenharmony_ci// ylong_http crate re-export. 246dbb5987Sopenharmony_ci#[cfg(any(feature = "ylong_base", feature = "tokio_base"))] 256dbb5987Sopenharmony_cipub use ylong_http::body::{EmptyBody, ReusableReader, TextBody}; 266dbb5987Sopenharmony_cipub use ylong_http::headers::{ 276dbb5987Sopenharmony_ci Header, HeaderName, HeaderValue, HeaderValueIter, HeaderValueIterMut, Headers, HeadersIntoIter, 286dbb5987Sopenharmony_ci HeadersIter, HeadersIterMut, 296dbb5987Sopenharmony_ci}; 306dbb5987Sopenharmony_cipub use ylong_http::request::method::Method; 316dbb5987Sopenharmony_cipub use ylong_http::request::uri::{Scheme, Uri}; 326dbb5987Sopenharmony_cipub use ylong_http::request::{Request, RequestPart}; 336dbb5987Sopenharmony_cipub use ylong_http::response::status::StatusCode; 346dbb5987Sopenharmony_cipub use ylong_http::response::ResponsePart; 356dbb5987Sopenharmony_cipub use ylong_http::version::Version; 366dbb5987Sopenharmony_ci 376dbb5987Sopenharmony_ci#[macro_use] 386dbb5987Sopenharmony_ci#[cfg(all( 396dbb5987Sopenharmony_ci any(feature = "async", feature = "sync"), 406dbb5987Sopenharmony_ci any(feature = "http1_1", feature = "http2"), 416dbb5987Sopenharmony_ci))] 426dbb5987Sopenharmony_cimod error; 436dbb5987Sopenharmony_ci 446dbb5987Sopenharmony_ci#[cfg(all(feature = "async", any(feature = "http1_1", feature = "http2")))] 456dbb5987Sopenharmony_cipub mod async_impl; 466dbb5987Sopenharmony_ci 476dbb5987Sopenharmony_ci#[cfg(all(feature = "sync", any(feature = "http1_1", feature = "http2")))] 486dbb5987Sopenharmony_cipub mod sync_impl; 496dbb5987Sopenharmony_ci 506dbb5987Sopenharmony_ci#[cfg(all( 516dbb5987Sopenharmony_ci any(feature = "async", feature = "sync"), 526dbb5987Sopenharmony_ci any(feature = "http1_1", feature = "http2"), 536dbb5987Sopenharmony_ci))] 546dbb5987Sopenharmony_cipub(crate) mod util; 556dbb5987Sopenharmony_ci 566dbb5987Sopenharmony_ci#[cfg(all( 576dbb5987Sopenharmony_ci any(feature = "async", feature = "sync"), 586dbb5987Sopenharmony_ci any(feature = "http1_1", feature = "http2"), 596dbb5987Sopenharmony_ci))] 606dbb5987Sopenharmony_cipub use error::{ErrorKind, HttpClientError}; 616dbb5987Sopenharmony_ci#[cfg(all( 626dbb5987Sopenharmony_ci any(feature = "async", feature = "sync"), 636dbb5987Sopenharmony_ci any(feature = "http1_1", feature = "http2"), 646dbb5987Sopenharmony_ci))] 656dbb5987Sopenharmony_cipub use util::*; 666dbb5987Sopenharmony_ci 676dbb5987Sopenharmony_ci// Runtime components import adapter. 686dbb5987Sopenharmony_ci#[cfg(any(feature = "tokio_base", feature = "ylong_base"))] 696dbb5987Sopenharmony_cipub(crate) mod runtime { 706dbb5987Sopenharmony_ci #[cfg(all(feature = "tokio_base", any(feature = "http2", feature = "http3")))] 716dbb5987Sopenharmony_ci pub(crate) use tokio::{ 726dbb5987Sopenharmony_ci io::{split, ReadHalf, WriteHalf}, 736dbb5987Sopenharmony_ci spawn, 746dbb5987Sopenharmony_ci sync::{ 756dbb5987Sopenharmony_ci mpsc::{ 766dbb5987Sopenharmony_ci channel as bounded_channel, error::SendError, unbounded_channel, 776dbb5987Sopenharmony_ci Receiver as BoundedReceiver, Sender as BoundedSender, UnboundedReceiver, 786dbb5987Sopenharmony_ci UnboundedSender, 796dbb5987Sopenharmony_ci }, 806dbb5987Sopenharmony_ci Mutex as AsyncMutex, MutexGuard, 816dbb5987Sopenharmony_ci }, 826dbb5987Sopenharmony_ci }; 836dbb5987Sopenharmony_ci #[cfg(all(feature = "tokio_base", feature = "async"))] 846dbb5987Sopenharmony_ci pub(crate) use tokio::{ 856dbb5987Sopenharmony_ci io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}, 866dbb5987Sopenharmony_ci net::TcpStream, 876dbb5987Sopenharmony_ci task::{spawn_blocking, JoinHandle}, 886dbb5987Sopenharmony_ci time::{sleep, timeout, Sleep}, 896dbb5987Sopenharmony_ci }; 906dbb5987Sopenharmony_ci #[cfg(feature = "ylong_base")] 916dbb5987Sopenharmony_ci pub(crate) use ylong_runtime::{ 926dbb5987Sopenharmony_ci io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}, 936dbb5987Sopenharmony_ci net::TcpStream, 946dbb5987Sopenharmony_ci spawn_blocking, 956dbb5987Sopenharmony_ci task::JoinHandle, 966dbb5987Sopenharmony_ci time::{sleep, timeout, Sleep}, 976dbb5987Sopenharmony_ci }; 986dbb5987Sopenharmony_ci // TODO add ReadHalf and WriteHalf 996dbb5987Sopenharmony_ci #[cfg(all(feature = "ylong_base", any(feature = "http2", feature = "http3")))] 1006dbb5987Sopenharmony_ci pub(crate) use ylong_runtime::{ 1016dbb5987Sopenharmony_ci spawn, 1026dbb5987Sopenharmony_ci sync::{ 1036dbb5987Sopenharmony_ci error::SendError, 1046dbb5987Sopenharmony_ci mpsc::{ 1056dbb5987Sopenharmony_ci bounded_channel, unbounded_channel, BoundedReceiver, BoundedSender, 1066dbb5987Sopenharmony_ci UnboundedReceiver, UnboundedSender, 1076dbb5987Sopenharmony_ci }, 1086dbb5987Sopenharmony_ci Mutex as AsyncMutex, MutexGuard, 1096dbb5987Sopenharmony_ci }, 1106dbb5987Sopenharmony_ci }; 1116dbb5987Sopenharmony_ci 1126dbb5987Sopenharmony_ci #[cfg(all(feature = "ylong_base", feature = "http2"))] 1136dbb5987Sopenharmony_ci pub(crate) use crate::{split, Reader as ReadHalf, Writer as WriteHalf}; 1146dbb5987Sopenharmony_ci} 115