wok view httpfs-fuse/stuff/httpfs.u @ rev 22840

Up cryptsetup (2.3.0, supports the BitLocker format)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Feb 12 11:04:59 2020 +0100 (2020-02-12)
parents
children
line source
1 --- httpfs.c
2 +++ httpfs.c
3 @@ -313,6 +313,7 @@
4 struct timeval timeout;
5 int bytes, status;
7 +moved:
8 #ifdef USE_SSL
9 if (protocol == PROTO_HTTPS) {
10 /* Make SSL connection. */
11 @@ -371,6 +372,27 @@
12 #endif
14 (void) sscanf(buf, "HTTP/1.1 %d ", &status);
15 + if (status == 301 || status == 302) {
16 + static int movedcnt = 0;
17 + b = strstr(buf,"Location:");
18 + if (b != NULL && ++movedcnt < 5) {
19 + char *eol = strchr(b, '\r');
20 + b = strstr(b,"http");
21 + if (eol == NULL || b == NULL)
22 + goto notmoved;
23 + *eol = 0;
24 + fprintf(stderr, "%s: HEAD (read) Status %d moved to %s\n",
25 + argv0, status, b);
26 + protocol = parseURL(b, host, &file_name, &port);
27 + if (protocol == -1)
28 + goto notmoved;
29 + close(sockfd);
30 + sockfd = open_client_socket(host, port);
31 + if (sockfd >= 0)
32 + goto moved;
33 + }
34 + }
35 +notmoved:
36 if (status != 200) {
37 fprintf(stderr, "%s: HEAD (read) failed with Status %d\n", argv0, status);
38 return -1;
39 @@ -892,6 +914,7 @@
40 struct stat mpstat;
41 int sr;
42 char* ri;
43 + char* s;
44 char* fusev[4];
46 argv0 = argv[0];
47 @@ -911,6 +934,14 @@
48 if (sockfd < 0)
49 return 1;
51 + s = httpfs_path;
52 + ri = rindex(file_name, '/');
53 + if (ri == (char *) 0) {
54 + ri = file_name;
55 + *s++ = '/';
56 + }
57 + strcpy(s, ri);
58 +
59 if (getSize() != 0)
60 return 1;
62 @@ -930,13 +961,6 @@
63 return 1;
64 }
66 - ri = rindex(file_name, '/');
67 - if (ri == (char *) 0) {
68 - httpfs_path[0] = '/';
69 - strcpy(&httpfs_path[1], file_name);
70 - } else
71 - strcpy(httpfs_path, ri);
72 -
73 fusev[0] = argv0;
74 fusev[1] = "-o";
75 fusev[2] = "nonempty";