7807b5c21514ccf345d2b610e6ba1ed39725d269 galt Mon Sep 23 00:36:32 2019 -0700 Incorporating change to support 307 and 308 redirect codes since the Encode portal seems to use them and customers are starting to ask for them. diff --git src/lib/net.c src/lib/net.c index 268ae00..e1af9d7 100644 --- src/lib/net.c +++ src/lib/net.c @@ -1451,31 +1451,31 @@ *rangeStart = atoll(y); if (z[0] != '\0') *rangeEnd = atoll(z); } } } boolean netSkipHttpHeaderLinesWithRedirect(int sd, char *url, char **redirectedUrl) /* Skip http header lines. Return FALSE if there's a problem. * The input is a standard sd or fd descriptor. * This is meant to be able work even with a re-passable stream handle, * e.g. can pass it to the pipes routines, which means we can't * attach a linefile since filling its buffer reads in more than just the http header. - * Handles 300, 301, 302, 303, 307 http redirects by setting *redirectedUrl to + * Handles 300, 301, 302, 303, 307, 308 http redirects by setting *redirectedUrl to * the new location. */ { char buf[2000]; char *line = buf; int maxbuf = sizeof(buf); int i=0; char c = ' '; int nread = 0; char *sep = NULL; char *headerName = NULL; char *headerVal = NULL; boolean redirect = FALSE; boolean byteRangeUsed = (strstr(url,";byterange=") != NULL); ssize_t byteRangeStart = -1; ssize_t byteRangeEnd = -1; @@ -1526,32 +1526,37 @@ if (sameString(line,"")) { break; /* End of Header found */ } if (startsWith("HTTP/", line)) { char *code; nextWord(&line); // version code = nextWord(&line); if (code == NULL) { warn("Strange http header on %s", url); return FALSE; } - if (startsWith("30", code) && isdigit(code[2]) - && ((code[2] >= '0' && code[2] <= '3') || code[2] == '7') && code[3] == 0) + if (sameString(code, "300") + || sameString(code, "301") + || sameString(code, "302") + || sameString(code, "303") + || sameString(code, "307") + || sameString(code, "308") + ) { redirect = TRUE; } else if (sameString(code, "305")) { mustUseProxy = TRUE; } else if (sameString(code, "407")) { mustUseProxyAuth = TRUE; } else if (byteRangeUsed /* hack for Apache bug 2.2.20 and 2.2.21 2011-10-21 should be OK to remove after one year. */ && !(sameString(code, "200") && byteRangeStart == 0 && byteRangeEnd == -1)) {