Skip to content

Commit c2be88c

Browse files
committed
Added flag to disable the check on server's support for HTTP range requests
1 parent b7f25ca commit c2be88c

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/link.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,12 @@ long path_download(const char *path, char *output_buf, size_t size,
735735
transfer_blocking(curl);
736736

737737
/* Check for range seek support */
738-
if (!strcasestr((header.data), "Accept-Ranges: bytes")) {
739-
fprintf(stderr, "Error: This web server does not support HTTP \
738+
if (!CONFIG.no_range_check) {
739+
if (!strcasestr((header.data), "Accept-Ranges: bytes")) {
740+
fprintf(stderr, "Error: This web server does not support HTTP \
740741
range requests\n");
741-
exit(EXIT_FAILURE);
742+
exit(EXIT_FAILURE);
743+
}
742744
}
743745

744746
free(header.data);

src/main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
7272
CONFIG.sonic_mode = 1;
7373
} else if (CONFIG.sonic_username || CONFIG.sonic_password) {
7474
fprintf(stderr,
75-
"Error: You have to supply both username and password to\
75+
"Error: You have to supply both username and password to \
7676
activate Sonic mode.\n");
7777
exit(EXIT_FAILURE);
7878
}
@@ -151,7 +151,8 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
151151
{"cache-location", required_argument, NULL, 'L'}, /* 14 */
152152
{"sonic-username", required_argument, NULL, 'L'}, /* 15 */
153153
{"sonic-password", required_argument, NULL, 'L'}, /* 16 */
154-
{"sonic-id3", no_argument, NULL, 'L'}, /* 17 */
154+
{"sonic-id3", no_argument, NULL, 'L'}, /* 17 */
155+
{"no-range-check", no_argument, NULL, 'L'}, /* 18 */
155156
{0, 0, 0, 0}
156157
};
157158
while ((c =
@@ -228,6 +229,9 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
228229
case 17:
229230
CONFIG.sonic_id3 = 1;
230231
break;
232+
case 18:
233+
CONFIG.no_range_check = 1;
234+
break;
231235
default:
232236
fprintf(stderr, "see httpdirfs -h for usage\n");
233237
return 1;
@@ -300,6 +304,8 @@ HTTPDirFS options:\n\
300304
--retry-wait Set delay in seconds before retrying an HTTP request\n\
301305
after encountering an error. (default: 5)\n\
302306
--user-agent Set user agent string (default: \"HTTPDirFS\")\n\
307+
--no-range-check Disable the build-in check for the server's support\n\
308+
for HTTP range requests\n\
303309
\n\
304310
For mounting a Airsonic / Subsonic server:\n\
305311
--sonic-username The username for your Airsonic / Subsonic server\n\

src/sonic.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <stdlib.h>
1212
#include <unistd.h>
1313

14-
1514
typedef struct {
1615
char *server;
1716
char *username;

src/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ void Config_init(void)
7272

7373
CONFIG.http_wait_sec = DEFAULT_HTTP_WAIT_SEC;
7474

75+
CONFIG.no_range_check = 0;
76+
7577
/*--------------- Cache related ---------------*/
7678
CONFIG.cache_enabled = 0;
7779

src/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ typedef struct {
5353
char *user_agent;
5454
/** \brief The waiting time after getting HTTP 429 (too many requests) */
5555
int http_wait_sec;
56+
/** \brief Disable check for the server's support of HTTP range request */
57+
int no_range_check;
5658

5759
/** \brief Whether cache mode is enabled */
5860
int cache_enabled;

0 commit comments

Comments
 (0)