• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ylong_http::body::sync_impl::Body;
17 use ylong_http::request::Request;
18 use ylong_http::response::Response;
19 
20 use crate::error::HttpClientError;
21 use crate::sync_impl::HttpBody;
22 use crate::util::dispatcher::Conn;
23 
24 #[cfg(feature = "http1_1")]
25 mod http1;
26 
27 pub(crate) trait StreamData: Read {
shutdown(&self)28     fn shutdown(&self);
29 }
30 
request<S, T>( conn: Conn<S>, request: &mut Request<T>, ) -> Result<Response<HttpBody>, HttpClientError> where T: Body, S: Read + Write + 'static,31 pub(crate) fn request<S, T>(
32     conn: Conn<S>,
33     request: &mut Request<T>,
34 ) -> Result<Response<HttpBody>, HttpClientError>
35 where
36     T: Body,
37     S: Read + Write + 'static,
38 {
39     match conn {
40         #[cfg(feature = "http1_1")]
41         Conn::Http1(http1) => http1::request(http1, request),
42 
43         #[cfg(feature = "http2")]
44         Conn::Http2(_) => todo!(),
45     }
46 }
47