Commit 34652a4f authored by Yamashita, Yuu's avatar Yamashita, Yuu
Browse files

Allow overriding HTTP client type based on environment variable...

Allow overriding HTTP client type based on environment variable `RUBY_BUILD_HTTP_CLIENT` (pyenv/pyenv#1126)
parent d7fa3adc
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -304,16 +304,22 @@ http() {
  local file="$3"
  [ -n "$url" ] || return 1

  local http_client
  if [ -n "${RUBY_BUILD_HTTP_CLIENT}" ]; then
    http_client="http_${method}_${RUBY_BUILD_HTTP_CLIENT}"
  else
    if type aria2c &>/dev/null; then
    "http_${method}_aria2c" "$url" "$file"
      http_client="http_${method}_aria2c"
    elif type curl &>/dev/null; then
    "http_${method}_curl" "$url" "$file"
      http_client="http_${method}_curl"
    elif type wget &>/dev/null; then
    "http_${method}_wget" "$url" "$file"
      http_client="http_${method}_wget"
    else
      echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2
      exit 1
    fi
  fi
  "${http_client}" "$url" "$file"
}

http_head_aria2c() {
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ export CC=cc
export -n RUBY_CONFIGURE_OPTS

setup() {
  ensure_not_found_in_path aria2c
  mkdir -p "$INSTALL_ROOT"
  stub md5 false
  stub curl false
+0 −2
Original line number Diff line number Diff line
@@ -3,10 +3,8 @@
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
export RUBY_BUILD_CURL_OPTS=

setup() {
  ensure_not_found_in_path aria2c
  mkdir "$RUBY_BUILD_CACHE_PATH"
}

+0 −5
Original line number Diff line number Diff line
@@ -3,11 +3,6 @@
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=
export RUBY_BUILD_CURL_OPTS=

setup() {
  ensure_not_found_in_path aria2c
}


@test "package URL without checksum" {
+2 −2
Original line number Diff line number Diff line
@@ -3,10 +3,8 @@
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=
export RUBY_BUILD_ARIA2_OPTS=

setup() {
  ensure_not_found_in_path aria2c
  export RUBY_BUILD_BUILD_PATH="${TMP}/source"
  mkdir -p "${RUBY_BUILD_BUILD_PATH}"
}
@@ -21,6 +19,8 @@ setup() {
}

@test "using aria2c if available" {
  export RUBY_BUILD_ARIA2_OPTS=
  export RUBY_BUILD_HTTP_CLIENT="aria2c"
  stub aria2c "--allow-overwrite=true --no-conf=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

  install_fixture definitions/without-checksum
Loading