Skip to content

Commit e23cdf2

Browse files
authored
Merge pull request #49 from sunfishcode/sunfishcode/try-into-outgoing
Rename `into_outgoing` and `try_into_incoming_response` for consistency
2 parents a2cd16d + 4424708 commit e23cdf2

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/http/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{body::IncomingBody, Body, Error, Request, Response, Result};
2-
use crate::http::request::into_outgoing;
3-
use crate::http::response::try_from_incoming_response;
2+
use crate::http::request::try_into_outgoing;
3+
use crate::http::response::try_from_incoming;
44
use crate::io::{self, AsyncOutputStream, AsyncPollable};
55
use crate::time::Duration;
66
use wasi::http::types::{OutgoingBody, RequestOptions as WasiRequestOptions};
@@ -20,7 +20,7 @@ impl Client {
2020

2121
/// Send an HTTP request.
2222
pub async fn send<B: Body>(&self, req: Request<B>) -> Result<Response<IncomingBody>> {
23-
let (wasi_req, body) = into_outgoing(req)?;
23+
let (wasi_req, body) = try_into_outgoing(req)?;
2424
let wasi_body = wasi_req.body().unwrap();
2525
let body_stream = wasi_body.write().unwrap();
2626

@@ -41,7 +41,7 @@ impl Client {
4141
// is to trap if we try and get the response more than once. The final
4242
// `?` is to raise the actual error if there is one.
4343
let res = res.get().unwrap().unwrap()?;
44-
try_from_incoming_response(res)
44+
try_from_incoming(res)
4545
}
4646

4747
/// Set timeout on connecting to HTTP server

src/http/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use wasi::http::types::Scheme;
44

55
pub use http::Request;
66

7-
pub(crate) fn into_outgoing<T>(request: Request<T>) -> Result<(OutgoingRequest, T)> {
7+
pub(crate) fn try_into_outgoing<T>(request: Request<T>) -> Result<(OutgoingRequest, T)> {
88
let wasi_req = OutgoingRequest::new(header_map_to_wasi(request.headers())?);
99

1010
let (parts, body) = request.into_parts();

src/http/response.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ use http::StatusCode;
1010

1111
pub use http::Response;
1212

13-
pub(crate) fn try_from_incoming_response(
14-
incoming: IncomingResponse,
15-
) -> Result<Response<IncomingBody>> {
13+
pub(crate) fn try_from_incoming(incoming: IncomingResponse) -> Result<Response<IncomingBody>> {
1614
let headers: HeaderMap = header_map_from_wasi(incoming.headers())?;
1715
// TODO: Does WASI guarantee that the incoming status is valid?
1816
let status =

0 commit comments

Comments
 (0)