Skip to content

Commit

Permalink
[clone] FAIL: try to communicate error codes after request
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 23, 2020
1 parent 174baa7 commit 2501ddd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions git-transport/src/client/http/curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ impl curl::easy::Handler for Handler {
}

fn header(&mut self, data: &[u8]) -> bool {
// TODO: check for HTTP status!
match self.send_header.as_mut() {
Some(writer) => writer.write_all(data).is_ok(),
None => false,
Expand Down Expand Up @@ -185,7 +184,17 @@ fn new_remote_curl() -> (
let handler = handle.get_mut();
handler.receive_body.take();
handler.send_header.take();
handler.send_data.take();
if let Some(data) = handler.send_data.take() {
let status = handle.response_code()?;
if status < 200 || status > 299 {
data.channel
.try_send(Err(io::Error::new(
io::ErrorKind::Other,
format!("Received HTTP status {}", status),
)))
.ok();
}
}
}
}
Ok(())
Expand Down
Binary file modified git-transport/tests/fixtures/v1/http-handshake.response
Binary file not shown.

0 comments on commit 2501ddd

Please sign in to comment.