|
1 | 1 | //! Process HTTP connections on the client.
|
2 | 2 |
|
3 |
| -use async_std::io::{self, BufReader, Read, Write}; |
| 3 | +use async_std::io::{self, BufReader, Read}; |
4 | 4 | use async_std::prelude::*;
|
5 | 5 | use async_std::task::{Context, Poll};
|
6 | 6 | use futures_core::ready;
|
@@ -48,19 +48,8 @@ impl Encoder {
|
48 | 48 | }
|
49 | 49 | }
|
50 | 50 |
|
51 |
| -/// Send an HTTP request over a stream. |
52 |
| -pub async fn connect<RW>(stream: RW, req: Request) -> Result<Response, std::io::Error> |
53 |
| -where |
54 |
| - RW: Read + Write + Clone + Send + Sync + Unpin + 'static, |
55 |
| -{ |
56 |
| - let mut req = encode(req).await?; |
57 |
| - io::copy(&mut req, &mut stream.clone()).await?; |
58 |
| - let res = decode(stream.clone()).await.unwrap(); // todo: convert to http_types::Error |
59 |
| - Ok(res) |
60 |
| -} |
61 |
| - |
62 | 51 | /// Encode an HTTP request on the client.
|
63 |
| -async fn encode(req: Request) -> Result<Encoder, std::io::Error> { |
| 52 | +pub async fn encode(req: Request) -> Result<Encoder, std::io::Error> { |
64 | 53 | let mut buf: Vec<u8> = vec![];
|
65 | 54 |
|
66 | 55 | let mut url = req.url().path().to_owned();
|
@@ -109,7 +98,7 @@ async fn encode(req: Request) -> Result<Encoder, std::io::Error> {
|
109 | 98 | }
|
110 | 99 |
|
111 | 100 | /// Decode an HTTP response on the client.
|
112 |
| -async fn decode<R>(reader: R) -> Result<Response, Exception> |
| 101 | +pub async fn decode<R>(reader: R) -> Result<Response, Exception> |
113 | 102 | where
|
114 | 103 | R: Read + Unpin + Send + Sync + 'static,
|
115 | 104 | {
|
|
0 commit comments