wok diff httpfs-fuse/stuff/httpfs.u @ rev 25037

Up glza (0.11.4)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat May 21 21:38:29 2022 +0000 (2022-05-21)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/httpfs-fuse/stuff/httpfs.u	Sat May 21 21:38:29 2022 +0000
     1.3 @@ -0,0 +1,75 @@
     1.4 +--- httpfs.c
     1.5 ++++ httpfs.c
     1.6 +@@ -313,6 +313,7 @@
     1.7 +     struct timeval timeout;
     1.8 +     int bytes, status;
     1.9 + 
    1.10 ++moved:
    1.11 + #ifdef USE_SSL
    1.12 +     if (protocol == PROTO_HTTPS) {
    1.13 + 	/* Make SSL connection. */
    1.14 +@@ -371,6 +372,27 @@
    1.15 + #endif
    1.16 + 
    1.17 +     (void) sscanf(buf, "HTTP/1.1 %d ", &status);
    1.18 ++    if (status == 301 || status == 302) {
    1.19 ++	static int movedcnt = 0;
    1.20 ++	b = strstr(buf,"Location:");
    1.21 ++	if (b != NULL && ++movedcnt < 5) {
    1.22 ++	    char *eol = strchr(b, '\r');
    1.23 ++	    b = strstr(b,"http");
    1.24 ++	    if (eol == NULL || b == NULL)
    1.25 ++		goto notmoved;
    1.26 ++	    *eol = 0;
    1.27 ++	    fprintf(stderr, "%s: HEAD (read) Status %d moved to %s\n",
    1.28 ++			argv0, status, b);
    1.29 ++	    protocol = parseURL(b, host, &file_name, &port);
    1.30 ++	    if (protocol == -1) 
    1.31 ++		goto notmoved;
    1.32 ++	    close(sockfd);
    1.33 ++	    sockfd = open_client_socket(host, port);
    1.34 ++	    if (sockfd >= 0)
    1.35 ++		goto moved;
    1.36 ++	}
    1.37 ++    }
    1.38 ++notmoved:
    1.39 +     if (status != 200) {
    1.40 + 	fprintf(stderr, "%s: HEAD (read) failed with Status %d\n", argv0, status);
    1.41 + 	return -1;
    1.42 +@@ -892,6 +914,7 @@
    1.43 +     struct stat mpstat;
    1.44 +     int sr;
    1.45 +     char* ri;
    1.46 ++    char* s;
    1.47 +     char* fusev[4];
    1.48 + 	
    1.49 +     argv0 = argv[0];
    1.50 +@@ -911,6 +934,14 @@
    1.51 +     if (sockfd < 0)
    1.52 + 	return 1;
    1.53 + 
    1.54 ++    s = httpfs_path;
    1.55 ++    ri = rindex(file_name, '/');
    1.56 ++    if (ri == (char *) 0) {
    1.57 ++	ri = file_name;
    1.58 ++	*s++ = '/';
    1.59 ++    }
    1.60 ++    strcpy(s, ri);
    1.61 ++
    1.62 +     if (getSize() != 0) 
    1.63 + 	return 1;
    1.64 + 
    1.65 +@@ -930,13 +961,6 @@
    1.66 + 	return 1;
    1.67 +     }
    1.68 +     
    1.69 +-    ri = rindex(file_name, '/');
    1.70 +-    if (ri == (char *) 0) {
    1.71 +-	httpfs_path[0] = '/';
    1.72 +-	strcpy(&httpfs_path[1], file_name);
    1.73 +-    } else
    1.74 +-	strcpy(httpfs_path, ri);
    1.75 +-
    1.76 +     fusev[0] = argv0;
    1.77 +     fusev[1] = "-o";
    1.78 +     fusev[2] = "nonempty";