@@ -24,22 +24,24 @@ async fn allowed_host_is_allowed() -> anyhow::Result<()> {
24
24
let mut state = test_instance_state ( "https://*" , true ) . await ?;
25
25
let mut wasi_http = OutboundHttpFactor :: get_wasi_http_impl ( & mut state) . unwrap ( ) ;
26
26
27
- // [100::] is an IPv6 "black hole ", which should always fail
27
+ // [100::] is the IPv6 "Discard Prefix ", which should always fail
28
28
let req = Request :: get ( "https://[100::1]:443" ) . body ( Default :: default ( ) ) ?;
29
29
let mut future_resp = wasi_http. send_request ( req, test_request_config ( ) ) ?;
30
30
future_resp. ready ( ) . await ;
31
31
32
- // We don't want to make an actual network request, so treat "connection refused" as success
32
+ // Different systems handle the discard prefix differently; some will
33
+ // immediately reject it while others will silently let it time out
33
34
match future_resp. unwrap_ready ( ) . unwrap ( ) {
34
- Ok ( _ ) => bail ! ( "expected Err, got Ok" ) ,
35
- Err ( err ) => assert ! ( matches! ( err , ErrorCode :: ConnectionRefused ) , "{err :?}") ,
35
+ Err ( ErrorCode :: ConnectionRefused | ErrorCode :: ConnectionTimeout ) => ( ) ,
36
+ other => bail ! ( "expected Err( ConnectionRefused | ConnectionTimeout ), got {other :?}") ,
36
37
} ;
37
38
Ok ( ( ) )
38
39
}
39
40
40
41
#[ tokio:: test]
41
42
async fn self_request_smoke_test ( ) -> anyhow:: Result < ( ) > {
42
43
let mut state = test_instance_state ( "http://self" , true ) . await ?;
44
+ // [100::] is the IPv6 "Discard Prefix", which should always fail
43
45
let origin = SelfRequestOrigin :: from_uri ( & Uri :: from_static ( "http://[100::1]" ) ) ?;
44
46
state. http . set_self_request_origin ( origin) ;
45
47
@@ -48,10 +50,11 @@ async fn self_request_smoke_test() -> anyhow::Result<()> {
48
50
let mut future_resp = wasi_http. send_request ( req, test_request_config ( ) ) ?;
49
51
future_resp. ready ( ) . await ;
50
52
51
- // We don't want to make an actual network request, so treat "connection refused" as success
53
+ // Different systems handle the discard prefix differently; some will
54
+ // immediately reject it while others will silently let it time out
52
55
match future_resp. unwrap_ready ( ) . unwrap ( ) {
53
- Ok ( _ ) => bail ! ( "expected Err, got Ok" ) ,
54
- Err ( err ) => assert ! ( matches! ( err , ErrorCode :: ConnectionRefused ) , "{err :?}") ,
56
+ Err ( ErrorCode :: ConnectionRefused | ErrorCode :: ConnectionTimeout ) => ( ) ,
57
+ other => bail ! ( "expected Err( ConnectionRefused | ConnectionTimeout ), got {other :?}") ,
55
58
} ;
56
59
Ok ( ( ) )
57
60
}
@@ -134,8 +137,8 @@ async fn test_instance_state(
134
137
fn test_request_config ( ) -> OutgoingRequestConfig {
135
138
OutgoingRequestConfig {
136
139
use_tls : false ,
137
- connect_timeout : Duration :: from_secs ( 60 ) ,
138
- first_byte_timeout : Duration :: from_secs ( 60 ) ,
139
- between_bytes_timeout : Duration :: from_secs ( 60 ) ,
140
+ connect_timeout : Duration :: from_millis ( 1 ) ,
141
+ first_byte_timeout : Duration :: from_millis ( 1 ) ,
142
+ between_bytes_timeout : Duration :: from_millis ( 1 ) ,
140
143
}
141
144
}
0 commit comments