File tree 2 files changed +10
-9
lines changed
2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ impl HTTPRequest {
44
44
path : String :: from ( & url. path ) ,
45
45
version : String :: from ( "HTTP/1.1" ) ,
46
46
headers : Vec :: new ( ) ,
47
- body : String :: from ( "Hello world " ) ,
47
+ body : String :: from ( "sending a request " ) ,
48
48
} ;
49
49
50
50
req. add_header ( String :: from ( "Host" ) , String :: from ( & url. host ) ) ;
Original file line number Diff line number Diff line change @@ -37,16 +37,17 @@ impl ParsedUrl {
37
37
url = u;
38
38
}
39
39
40
- let host;
41
- let path;
40
+ let mut host = String :: new ( ) ;
41
+ let mut path = String :: new ( ) ;
42
42
{
43
43
let v: Vec < & str > = url. splitn ( 2 , '/' ) . collect ( ) ;
44
44
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 ] ) ;
47
48
} 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" ) ;
50
51
} else {
51
52
panic ! ( "invalid url {}" , url) ;
52
53
}
@@ -66,9 +67,9 @@ impl ParsedUrl {
66
67
67
68
Self {
68
69
scheme : String :: from ( "http" ) ,
69
- host : host. to_string ( ) ,
70
+ host : host,
70
71
port : port,
71
- path : path. to_string ( ) ,
72
+ path : path,
72
73
}
73
74
}
74
75
}
You can’t perform that action at this time.
0 commit comments