diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-25 17:18:14 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-25 17:18:14 -0500 |
commit | 5c3c9b170f1415fcbb4c0de28339467bcbca5e29 (patch) | |
tree | c871a52c7611df78519c8673e2a1a7034bf337ba /ipfs-api/src/read.rs | |
parent | be4d9527b0ee4830d5434e6e70415d2f18af0180 (diff) |
add dht and better serialization
Diffstat (limited to 'ipfs-api/src/read.rs')
-rw-r--r-- | ipfs-api/src/read.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/ipfs-api/src/read.rs b/ipfs-api/src/read.rs index 5396f46..5f60c69 100644 --- a/ipfs-api/src/read.rs +++ b/ipfs-api/src/read.rs @@ -69,13 +69,20 @@ where // Err(e) => { if self.parse_stream_error { - let raw = Raw::from(slice); - - match XStreamError::parse_header(&raw) { - Ok(stream_error) => Err( - ErrorKind::StreamError(stream_error.error).into(), - ), - Err(_) => Err(e.into()), + match slice.iter().position(|&x| x == b':') { + Some(colon) + if &slice[..colon] == XStreamError::header_name().as_bytes() => { + let raw = Raw::from(&slice[colon + 2..]); + + match XStreamError::parse_header(&raw) { + Ok(stream_error) => Err( + ErrorKind::StreamError(stream_error.error) + .into(), + ), + Err(_) => Err(e.into()), + } + } + _ => Err(e.into()), } } else { Err(e.into()) |