Skip to content

Commit a32c7b7

Browse files
committed
browser-rs: fix parsed_url.path to include a slash
1 parent e3b5bbf commit a32c7b7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

app/browser-rs/src/http.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl HTTPRequest {
4444
path: String::from(&url.path),
4545
version: String::from("HTTP/1.1"),
4646
headers: Vec::new(),
47-
body: String::from("Hello world"),
47+
body: String::from("sending a request"),
4848
};
4949

5050
req.add_header(String::from("Host"), String::from(&url.host));

app/browser-rs/src/main.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ impl ParsedUrl {
3737
url = u;
3838
}
3939

40-
let host;
41-
let path;
40+
let mut host = String::new();
41+
let mut path = String::new();
4242
{
4343
let v: Vec<&str> = url.splitn(2, '/').collect();
4444
if v.len() == 2 {
45-
host = v[0];
46-
path = v[1];
45+
host.push_str(v[0]);
46+
path.push_str("/");
47+
path.push_str(v[1]);
4748
} else if v.len() == 1 {
48-
host = v[0];
49-
path = "/index.html";
49+
host.push_str(v[0]);
50+
path.push_str("/index.html");
5051
} else {
5152
panic!("invalid url {}", url);
5253
}
@@ -66,9 +67,9 @@ impl ParsedUrl {
6667

6768
Self {
6869
scheme: String::from("http"),
69-
host: host.to_string(),
70+
host: host,
7071
port: port,
71-
path: path.to_string(),
72+
path: path,
7273
}
7374
}
7475
}

0 commit comments

Comments
 (0)