a4305926f0e89a8af454e34709174f7ea07fb5bb galt Thu Mar 6 00:41:37 2025 -0800 Add support for DropBox for hubs and customtracks using byteranges. fixes #35342 diff --git src/lib/net.c src/lib/net.c index d5b6db37bf1..90da0944d83 100644 --- src/lib/net.c +++ src/lib/net.c @@ -1365,30 +1365,33 @@ if (sd < 0) return -1; /* Ask remote server for a file. */ char *urlForProxy = NULL; if (proxyUrl) { /* trim off the byterange part at the end of url because proxy does not understand it. */ urlForProxy = cloneString(url); char *x = strrchr(urlForProxy, ';'); if (x && startsWith(";byterange=", x)) *x = 0; } dyStringPrintf(dy, "%s %s %s\r\n", method, proxyUrl ? urlForProxy : npu.file, protocol); freeMem(urlForProxy); +if (sameString(npu.host, "www.dropbox.com") || endsWith(npu.host, ".dl.dropboxusercontent.com")) + dyStringPrintf(dy, "User-Agent: %s\r\n", "curl/8"); +else dyStringPrintf(dy, "User-Agent: %s\r\n", agent); dyStringPrintf(dy, "Host: "); netHandleHostForIpv6(&npu, dy); boolean portIsDefault = FALSE; /* do not need the 80 since it is the default */ if (sameString(npu.protocol, "http" ) && sameString("80", npu.port)) portIsDefault = TRUE; if (sameString(npu.protocol, "https" ) && sameString("443", npu.port)) portIsDefault = TRUE; if (!portIsDefault) { dyStringAppendC(dy, ':'); dyStringAppend(dy, npu.port); @@ -1799,30 +1802,41 @@ * int newSd = 0; * netSkipHttpHeaderLine(sd, url, &newSd, &newUrl); * if (newUrl != NULL) * // Update sd with newSd, free url if appropriate and replace it with newUrl, etc. * // free newUrl when finished. * This routine handles up to 5 steps of redirection. * The logic to this routine is also complicated a little to make it work in a pipe, which means we * can't attach a lineFile since filling the lineFile buffer reads in more than just the http header. */ { int redirectCount = 0; while (TRUE) { /* url needed for err msgs, and to return redirect location */ char *newUrl = NULL; boolean success = netSkipHttpHeaderLinesWithRedirect(sd, url, &newUrl); + + // removing any hashkey from redirect location + if (newUrl) + { + char *hashKey = strchr(newUrl, '#'); // truncate at hashkey + if (hashKey) + { + *hashKey = 0; + } + } + if (success && !newUrl) /* success after 0 to 5 redirects */ { if (redirectCount > 0) { *redirectedSd = sd; *redirectedUrl = url; } else { *redirectedSd = -1; *redirectedUrl = NULL; } return TRUE; } close(sd);