summaryrefslogtreecommitdiff
path: root/usr.bin/fetch/http.c
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1999-02-25 18:36:32 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1999-02-25 18:36:32 +0000
commit4fea87acee3f69f5760e61235189ce154ceba1eb (patch)
tree33625d233e46f1ed986126d0cac6ebad6908fc8b /usr.bin/fetch/http.c
parentfce81da2c38c83f21b8f36937e7636060ca36358 (diff)
Notes
Diffstat (limited to 'usr.bin/fetch/http.c')
-rw-r--r--usr.bin/fetch/http.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c
index 2f08c1d2be0f..21d6c2ec0e8d 100644
--- a/usr.bin/fetch/http.c
+++ b/usr.bin/fetch/http.c
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: http.c,v 1.23 1999/01/15 16:56:22 wollman Exp $
+ * $Id: http.c,v 1.26 1999/02/23 18:51:13 wollman Exp $
*/
#include <sys/types.h>
@@ -165,7 +165,7 @@ http_parse(struct fetch_state *fs, const char *u)
strncat(hostname, p, q - p);
p = slash;
- if (colon && colon + 1 != slash) {
+ if (q == colon && colon + 1 != slash) {
unsigned long ul;
char *ep;
@@ -703,7 +703,6 @@ got100reply:
line[linelen - 1] = '\0'; /* turn line into a string */
status = http_first_line(line);
- /* In the future, we might handle redirection and other responses. */
switch(status) {
case 100: /* Continue */
goto got100reply;
@@ -715,17 +714,29 @@ got100reply:
/* can only happen when restarting */
break;
case 301: /* Resource has moved permanently */
- if (!fs->fs_auto_retry)
+ if (fs->fs_auto_retry < 1)
errstr = safe_strdup(line);
else
redirection = 301;
break;
case 302: /* Resource has moved temporarily */
/*
- * We don't test fs->fs_auto_retry here so that this
- * sort of redirection is transparent to the user.
+ * We formerly didn't test fs->fs_auto_retry here,
+ * so that this sort of redirection would be transparent
+ * to the user. Unfortunately, there are a lot of idiots
+ * out there running Web sites, and some of them have
+ * decided to implement the following stupidity: rather
+ * than returning the correct `404 Not Found' error
+ * when something is not found, they instead return
+ * a 302 redirect, giving the erroneous impression that
+ * the requested resource actually exists. This
+ * breaks any client which expects a non-existent resource
+ * to elicit a 40x response. Grrr.
*/
- redirection = 302;
+ if (fs->fs_auto_retry < 0) /* -A flag */
+ errstr = safe_strdup(line);
+ else
+ redirection = 302;
break;
case 304: /* Object is unmodified */
if (fs->fs_mirror) {