Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #6866 from paritytech/td-fix-dapps-tests
Browse files Browse the repository at this point in the history
Fix dapps tests in master
  • Loading branch information
debris committed Oct 24, 2017
2 parents 097815c + dd21e61 commit 3e5d9b9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions devtools/src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::thread;
use std::time::Duration;
use std::io::{Read, Write};
use std::io::{self, Read, Write};
use std::str::{self, Lines};
use std::net::{TcpStream, SocketAddr};

Expand Down Expand Up @@ -83,9 +83,18 @@ pub fn request(address: &SocketAddr, request: &str) -> Response {
req.set_read_timeout(Some(Duration::from_secs(2))).unwrap();
req.write_all(request.as_bytes()).unwrap();

let mut response = String::new();
let _ = req.read_to_string(&mut response);
let mut response = Vec::new();
loop {
let mut chunk = [0; 32 *1024];
match req.read(&mut chunk) {
Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => break,
Err(err) => panic!("Unable to read response: {:?}", err),
Ok(0) => break,
Ok(read) => response.extend_from_slice(&chunk[..read]),
}
}

let response = String::from_utf8_lossy(&response).into_owned();
let mut lines = response.lines();
let status = lines.next().expect("Expected a response").to_owned();
let headers_raw = read_block(&mut lines, false);
Expand Down

0 comments on commit 3e5d9b9

Please sign in to comment.