Skip to content

Commit

Permalink
[clone] quick hack to finish http set service, but something is serio…
Browse files Browse the repository at this point in the history
…usly wrong…

…as it depletes the stream immediately after reading the first line from
the body, but at least it consistently finds the flush bytes now.
But how can it possibly skip everything inbetween?
  • Loading branch information
Byron committed Aug 22, 2020
1 parent bab3ec3 commit dd93504
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions git-transport/src/client/git/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub fn capabilties_and_possibly_refs<'a, T: io::Read>(
let capabilities = rd
.peek_line()
.ok_or(crate::client::Error::ExpectedLine("capabilities or version"))???;
dbg!(capabilities);
let (capabilities, delimiter_position) = Capabilities::from_bytes(
capabilities
.to_text()
Expand Down
35 changes: 21 additions & 14 deletions git-transport/src/client/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::client::SetServiceResponse;
use crate::client::{git, SetServiceResponse};
use crate::{Protocol, Service};
use quick_error::quick_error;
use std::io::BufRead;
use std::{borrow::Cow, convert::Infallible, io};

quick_error! {
Expand Down Expand Up @@ -87,18 +86,26 @@ impl crate::client::TransportSketch for Transport {
if self.version != Protocol::V1 {
dynamic_headers.push(Cow::Owned(format!("Git-Protocol: version={}", self.version as usize)));
}
let GetResponse { headers, body } = self.http.get(&url, static_headers.iter().chain(&dynamic_headers))?;
eprintln!("HEADERS");
for header in headers.lines() {
let header = header?;
eprintln!("{}", header);
}
eprintln!("BODY");
for line in body.lines() {
let line = line?;
eprintln!("{}", line);
}
unimplemented!("set service http")
let GetResponse { mut headers, mut body } =
self.http.get(&url, static_headers.iter().chain(&dynamic_headers))?;
io::copy(&mut headers, &mut io::stderr())?;

// TODO: keep it around, it's expensive
let mut rd = git_packetline::Reader::new(&mut body, None);
let _service = rd
.read_line()
.ok_or(crate::client::Error::ExpectedLine("server marker"))???; // TODO: verify this line
dbg!(_service.as_bstr());
let (capabilities, refs) = git::recv::capabilties_and_possibly_refs(&mut rd)?;
Ok(SetServiceResponse {
actual_protocol: Protocol::V1, // TODO
capabilities,
refs: refs.map(|mut r| {
let mut v = Vec::new();
io::copy(&mut r, &mut v).ok();
Box::new(io::Cursor::new(v)) as Box<dyn io::BufRead>
}),
})
}
}

Expand Down
1 change: 0 additions & 1 deletion git-transport/tests/client/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ mod upload_pack {
use git_transport::{client::TransportSketch, Protocol, Service};

#[test]
#[ignore]
fn clone_v1() -> crate::Result {
let mut server = serve_once("v1/http-handshake.response");
let mut c = git_transport::client::http::connect(
Expand Down

0 comments on commit dd93504

Please sign in to comment.