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