pub trait Http {
type Headers: BufRead + Unpin;
type ResponseBody: BufRead;
type PostBody: Write;
fn get(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<GetResponse<Self::Headers, Self::ResponseBody>, Error>;
fn post(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<PostResponse<Self::Headers, Self::ResponseBody, Self::PostBody>, Error>;
}Expand description
A trait to abstract the HTTP operations needed to power all git interactions: read via GET and write via POST.
Required Associated Types
type ResponseBody: BufRead
type ResponseBody: BufRead
A type providing the response.
Required Methods
fn get(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<GetResponse<Self::Headers, Self::ResponseBody>, Error>
fn get(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<GetResponse<Self::Headers, Self::ResponseBody>, Error>
Initiate a GET request to url provided the given headers.
The headers are provided verbatim and include both the key as well as the value.
fn post(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<PostResponse<Self::Headers, Self::ResponseBody, Self::PostBody>, Error>
fn post(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<PostResponse<Self::Headers, Self::ResponseBody, Self::PostBody>, Error>
Initiate a POST request to url providing with the given headers.
The headers are provided verbatim and include both the key as well as the value.
Note that the PostResponse contains the post_body field which implements std::io::Write
and is expected to receive the body to post to the server. It must be dropped before reading the response
to prevent deadlocks.