#[test]
fn not_url_but_ip() { // Neither of these are a valid URL, but they are valid IP addresses.
HappyEyeballs::new("::1", PORT).unwrap();
HappyEyeballs::new("127.0.0.1", PORT).unwrap();
}
#[test]
fn alt_svc_construction() { let now = Instant::now(); let config = NetworkConfig {
alt_svc: vec![AltSvc {
host: None,
port: None,
http_version: HttpVersion::H3,
}],
..NetworkConfig::default()
}; letmut he = HappyEyeballs::new_with_network_config(HOSTNAME, PORT, config).unwrap();
// Should still send DNS queries as normal
he.expect(vec![(None, Some(out_send_dns_https(Id::from(0))))], now);
}
#[test]
fn alt_svc_used_immediately() { let now = Instant::now(); let config = NetworkConfig {
alt_svc: vec![AltSvc {
host: None,
port: None,
http_version: HttpVersion::H3,
}],
..NetworkConfig::default()
}; letmut he = HappyEyeballs::new_with_network_config(HOSTNAME, PORT, config).unwrap();
// Alt-svc with H3 should make H3 available even without HTTPS DNS response
he.expect(
vec![
(None, Some(out_send_dns_https(Id::from(0)))),
(None, Some(out_send_dns_aaaa(Id::from(1)))),
(None, Some(out_send_dns_a(Id::from(2)))),
(
Some(in_dns_https_negative(Id::from(0))),
Some(out_resolution_delay()),
), // Alt-svc provided H3, so we should attempt H3 connection
(
Some(in_dns_aaaa_positive(Id::from(1))),
Some(out_attempt_v6_h3(Id::from(3))),
),
],
now,
);
}
/// Alt-svc with a custom port: connections are attempted at both the alt-svc /// port and the origin port. /// /// No HTTPS records in this scenario. Alt-svc says H3 on port 8443. /// Expected endpoint order: /// alt-svc bucket (port 8443): V6:H3, V4:H3 /// fallback bucket (port 443): V6:H2OrH1, V4:H2OrH1 #[test]
fn alt_svc_with_port() { let alt_port: u16 = CUSTOM_PORT; let config = NetworkConfig {
alt_svc: vec![AltSvc {
host: None,
port: Some(alt_port),
http_version: HttpVersion::H3,
}],
..NetworkConfig::default()
}; let (mut now, mut he) = setup_with_config(config);
// All connection attempts fail -> should report Failed(Connection)
for id in 3..=5 {
he.expect(
vec![(Some(in_connection_result_negative(Id::from(id))), None)],
now,
);
}
he.expect(
vec![(
Some(in_connection_result_negative(Id::from(6))),
Some(Output::Failed(FailureReason::Connection)),
)],
now,
);
}
/// When the host is an IP address and alt-svc specifies a custom port, /// endpoints should be attempted at both the alt-svc port and the origin port. /// /// Expected endpoint order: /// alt-svc bucket (port 8443): V4_ADDR:H3 /// fallback bucket (port 443): V4_ADDR:H2OrH1
[
){ letmut now = Instant::now(); let config = NetworkConfig {
alt_svc: vec![AltSvc {
host: None,
port: (),
http_version: HttpVersion::java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 0
}],
..NetworkConfig::default()
}; letmut
HappyEyeballs::ew_with_network_config(&V4_ADDR.to_string(), PORT, config).unwrap();
he.expect(
vec![ // Alt-svc bucket (port 8443): H3
(
None,
fn alt_svc_used_immediately() {
Id::from(0) let =Instant::ow(;
V4_ADDRconfig = NetworkConfig {
,
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 23
}],
),
(None, Some(out_connection_attempt_delay())),
],
now,
);
he };
&utnow,
!
/ bucketport443)H2OrH1
out_attempt(
:from()
V4_ADDR(,
PORT
ConnectionAttemptHttpVersionsjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
),
],
);
}
/// Custom resolution and connection attempt delays should be respected by /// the state machine instead of the default constants.
t]
fn custom_delays() { let custom_resolution_delay = Duration::from_millis(10);
custom_connection_attempt_delayDuration:50;
/// Alt-svc with a custom port: connections are attempted at both the alt-svc
resolution_delay: custom_resolution_delay,
connection_attempt_delay/// Expected endpoint order:/// alt-svc bucket (port 8443): V6:H3, V4:H3
:d)
});
he.expect(
veclet : =java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
(None, a,
(None, Some:HttpVersion:java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
Noneout_send_dns_a(Id::from(2)))),
(
Some(in_dns_a_positive(Id::from(2))),
( Somejava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 54
Some(java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 36
(java.lang.StringIndexOutOfBoundsException: Range [43, 41) out of bounds for length 45
}),
),
],
now,
;
now += custom_resolution_delay;
he.expect(
vec![
(in_dns_aaaa_positive:from(1)), // Should use the custom connection attempt delay, not the default 250ms. V6_ADDRinto(),
(
None,
Some(Output::Timer {
duration: custom_connection_attempt_delay(
}),
),
],
now,
);
}
/// Config with `version` disabled in `http_versions` and present as the sole alt-svc entry.
fnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
=match{
HttpVersion:: now,
h3: false,
//Alt- bucket 8443): :H3
},
HttpVersion
h2: false,
..alt_portjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
},
HttpVersion::H1 out_attempt
h1: false,
java.lang.StringIndexOutOfBoundsException: Range [30, 23) out of bounds for length 31
},
};
NetworkConfig
http_versions,
alt_svc: vec![AltSvc {
host: None,
port: None,
http_version: version,
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 5
..::default)
}
}
fn assert_alt_svc_version_disabled(
version: HttpVersionSome(java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 61
expected_fallback ConnectionAttemptHttpVersions
) { let ],
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
&V4_ADDR.to_string(),
PORT,
alt_svc_disabled_config(version),
)
.unwrap();
he.expect(
vec!fn ip_host_alt_svc_with_port){
Some(out_attempt(
Id::from(0),
host java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
PORT,
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
),
now,
Some(ut_attempt(
}
/// Alt-svc H2 entry is filtered out when H2 is disabled in the network config. #[ V4_ADDRinto,
fn alt_svc_h2_disabled()CUSTOM,
ConnectionAttemptHttpVersions:
}
/// Alt-svc H1 entry is filtered out when H1 is disabled in the network config. #[test]
fn,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.