Fix updater to follow redirects on latest
This commit is contained in:
parent
409fb0a41d
commit
86e7015528
|
@ -103,8 +103,22 @@ impl AdoptiumAPI {
|
||||||
.client
|
.client
|
||||||
.get_async(url)
|
.get_async(url)
|
||||||
.await
|
.await
|
||||||
.context("Failed to request release")?
|
.context("Failed to request release")?;
|
||||||
.into_body();
|
// If we get a 301, respond to it
|
||||||
|
if response.status().as_u16() == 301 {
|
||||||
|
let location = response
|
||||||
|
.headers()
|
||||||
|
.get("location")
|
||||||
|
.context("Failed to get redirect location")?
|
||||||
|
.to_str()
|
||||||
|
.context("Failed to parse redirect location")?;
|
||||||
|
response = self
|
||||||
|
.client
|
||||||
|
.get_async(location)
|
||||||
|
.await
|
||||||
|
.context("Failed to request release")?;
|
||||||
|
}
|
||||||
|
let mut response = response.into_body();
|
||||||
let mut body = String::new();
|
let mut body = String::new();
|
||||||
response
|
response
|
||||||
.read_to_string(&mut body)
|
.read_to_string(&mut body)
|
||||||
|
@ -137,7 +151,7 @@ impl AdoptiumAPI {
|
||||||
let latest: OutputRelease = self
|
let latest: OutputRelease = self
|
||||||
.latest(input_versions.most_recent_feature_version, arch, true)
|
.latest(input_versions.most_recent_feature_version, arch, true)
|
||||||
.await
|
.await
|
||||||
.context("Failed to get version")?
|
.context("Failed to get version - latest")?
|
||||||
.into();
|
.into();
|
||||||
let stable: OutputRelease = self
|
let stable: OutputRelease = self
|
||||||
.latest(
|
.latest(
|
||||||
|
@ -146,7 +160,7 @@ impl AdoptiumAPI {
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("Failed to get version")?
|
.context("Failed to get version - stable")?
|
||||||
.into();
|
.into();
|
||||||
let lts: OutputRelease = self
|
let lts: OutputRelease = self
|
||||||
.latest(
|
.latest(
|
||||||
|
@ -156,7 +170,7 @@ impl AdoptiumAPI {
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("Failed to get version")?
|
.context("Failed to get version - lts")?
|
||||||
.into();
|
.into();
|
||||||
Ok(OutputReleases {
|
Ok(OutputReleases {
|
||||||
versions,
|
versions,
|
||||||
|
|
Loading…
Reference in New Issue