Skip to content

Commit

Permalink
fix: Adapt to recent changes in JDK download URL response
Browse files Browse the repository at this point in the history
Parse the JDK redirect URL for a case insensitive redirect location

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307 shows the response as:

> location: /en-US/docs/Learn/JavaScript/Client-side_web_APIs/Fetching_data
> content-type: text/plain; charset=utf-8
> date: Fri, 19 Jul 2024 12:57:17 GMT

Previously, the response must have used "Location:" rather than "location:"
  • Loading branch information
MarkEWaite committed Oct 7, 2024
1 parent 945dfc8 commit 464d336
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions adoptium-get-jdk-link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ for ARCH in ${ARCHS}; do
URL="https://api.adoptium.net/v3/binary/version/jdk-${ENCODED_ARCHIVE_DIRECTORY}/${OS_TYPE}/${ARCH}/jdk/hotspot/normal/eclipse?project=jdk"

if ! RESPONSE=$(curl --fail --silent --show-error --retry 5 --retry-connrefused --head "${URL}"); then
echo "Error: Failed to fetch the URL for architecture ${ARCH}. Exiting with status 1." >&2
echo "Error: Failed to fetch the URL for architecture ${ARCH} for ${URL}. Exiting with status 1." >&2
echo "Response: ${RESPONSE}" >&2
exit 1
fi

# Extract the redirect URL from the HTTP response
REDIRECTED_URL=$(echo "${RESPONSE}" | grep Location | awk '{print $2}' | tr -d '\r')
REDIRECTED_URL=$(echo "${RESPONSE}" | grep -i location | awk '{print $2}' | tr -d '\r')

# If no redirect URL was found, exit the script with an error message
if [ -z "${REDIRECTED_URL}" ]; then
echo "Error: No redirect URL found for architecture ${ARCH}. Exiting with status 1." >&2
echo "Error: No redirect URL found for architecture ${ARCH} for ${URL}. Exiting with status 1." >&2
echo "Response: ${RESPONSE}" >&2
exit 1
fi
Expand Down

0 comments on commit 464d336

Please sign in to comment.