1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 use std::io::{Read, Write};
15 
16 use super::{Body, Request, Response};
17 use crate::error::HttpClientError;
18 use crate::sync_impl::HttpBody;
19 use crate::util::dispatcher::Conn;
20 
21 #[cfg(feature = "http1_1")]
22 mod http1;
23 
24 pub(crate) trait StreamData: Read {
shutdown(&self)25     fn shutdown(&self);
26 }
27 
request<S, T>( conn: Conn<S>, request: &mut Request<T>, ) -> Result<Response<HttpBody>, HttpClientError> where T: Body, S: Read + Write + 'static,28 pub(crate) fn request<S, T>(
29     conn: Conn<S>,
30     request: &mut Request<T>,
31 ) -> Result<Response<HttpBody>, HttpClientError>
32 where
33     T: Body,
34     S: Read + Write + 'static,
35 {
36     match conn {
37         #[cfg(feature = "http1_1")]
38         Conn::Http1(http1) => http1::request(http1, request),
39 
40         #[cfg(feature = "http2")]
41         Conn::Http2(_) => todo!(),
42     }
43 }
44