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>; fn configure(
        &mut self,
        config: &dyn Any
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>; }
Available on crate features blocking-client and http-client only.
Expand description

A trait to abstract the HTTP operations needed to power all git interactions: read via GET and write via POST. Note that 401 must be turned into std::io::Error(PermissionDenied), and other non-success http stati must be transformed into std::io::Error(Other)

Required Associated Types

A type providing headers line by line.

A type providing the response.

A type allowing to write the content to post.

Required Methods

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.

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.

Pass config which can deserialize in the implementation’s configuration, as documented separately.

The caller must know how that config data looks like for the intended implementation.

Implementors