本文介绍了使用wget从正确的Apache Mirror下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用特定示例,我想下载Hadoop 2.7.2的二进制版本。 指向,然后按位置指向最近的镜像。对我来说,这是。

To use a specific example, I want to download the binary release of Hadoop 2.7.2. The web site points to http://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz which then points to the closest mirror by location. For me that is http://xenia.sote.hu/ftp/mirrors/www.apache.org/hadoop/core/hadoop-2.7.2/hadoop-2.7.2.tar.gz.

我想实际在shell脚本(具体来说是Dockerfile)中下载此文件。我宁愿使用与位置无关的URL进行下载,这样,如果有人在世界的另一端运行脚本,他们将不会使用同一镜像。

I want to actually download this in a shell script (a Dockerfile to be specific). I would prefer to use a location-agnostic URL for the download so that if someone runs the script on the other end of the world, they would not use the same mirror.

是否存在可以与 wget curl 动态链接到最近的镜像的URL?该特定文件的URL是什么?

Is there a URL I could use with wget or curl that dynamically redirects to the closest mirror? What would that URL be for this specific file?

推荐答案

的源代码实际上指出操作 filename 查询参数可用于在自动选择的镜像而不是通常的HTML镜像选择页面上生成到请求文件的重定向。

The source code of closer.lua actually states that the action and filename query parameters may be used to produce a redirect to the requested file on the automatically chosen mirror instead of the usual HTML mirror selection page.

因此您可以直接通过以下URL下载文件::

So you can download the files directly via this URL: https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz:

GET /dyn/mirrors/mirrors.cgi?action=download&filename=hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: www.apache.org



HTTP/1.1 302 Found
Cache-Control: max-age=3600
Connection: Keep-Alive
Content-Length: 0
Date: Mon, 13 Mar 2017 18:08:00 GMT
Expires: Mon, 13 Mar 2017 19:08:00 GMT
Keep-Alive: timeout=30, max=100
Location: http://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.apache.org/dist/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
Server: Apache/2.4.7 (Ubuntu)

这篇关于使用wget从正确的Apache Mirror下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 13:56