Added flag to disable the check on server's support for HTTP range requests

This commit is contained in:
Fufu Fang 2019-10-27 21:54:13 +00:00
parent b7f25ca7ed
commit c2be88c6e4
No known key found for this signature in database
GPG Key ID: 0F6BB5EF6F8BB729
5 changed files with 17 additions and 6 deletions

View File

@ -735,10 +735,12 @@ long path_download(const char *path, char *output_buf, size_t size,
transfer_blocking(curl);
/* Check for range seek support */
if (!strcasestr((header.data), "Accept-Ranges: bytes")) {
fprintf(stderr, "Error: This web server does not support HTTP \
if (!CONFIG.no_range_check) {
if (!strcasestr((header.data), "Accept-Ranges: bytes")) {
fprintf(stderr, "Error: This web server does not support HTTP \
range requests\n");
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}
free(header.data);

View File

@ -72,7 +72,7 @@ int main(int argc, char **argv)
CONFIG.sonic_mode = 1;
} else if (CONFIG.sonic_username || CONFIG.sonic_password) {
fprintf(stderr,
"Error: You have to supply both username and password to\
"Error: You have to supply both username and password to \
activate Sonic mode.\n");
exit(EXIT_FAILURE);
}
@ -151,7 +151,8 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
{"cache-location", required_argument, NULL, 'L'}, /* 14 */
{"sonic-username", required_argument, NULL, 'L'}, /* 15 */
{"sonic-password", required_argument, NULL, 'L'}, /* 16 */
{"sonic-id3", no_argument, NULL, 'L'}, /* 17 */
{"sonic-id3", no_argument, NULL, 'L'}, /* 17 */
{"no-range-check", no_argument, NULL, 'L'}, /* 18 */
{0, 0, 0, 0}
};
while ((c =
@ -228,6 +229,9 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
case 17:
CONFIG.sonic_id3 = 1;
break;
case 18:
CONFIG.no_range_check = 1;
break;
default:
fprintf(stderr, "see httpdirfs -h for usage\n");
return 1;
@ -300,6 +304,8 @@ HTTPDirFS options:\n\
--retry-wait Set delay in seconds before retrying an HTTP request\n\
after encountering an error. (default: 5)\n\
--user-agent Set user agent string (default: \"HTTPDirFS\")\n\
--no-range-check Disable the build-in check for the server's support\n\
for HTTP range requests\n\
\n\
For mounting a Airsonic / Subsonic server:\n\
--sonic-username The username for your Airsonic / Subsonic server\n\

View File

@ -11,7 +11,6 @@
#include <stdlib.h>
#include <unistd.h>
typedef struct {
char *server;
char *username;

View File

@ -72,6 +72,8 @@ void Config_init(void)
CONFIG.http_wait_sec = DEFAULT_HTTP_WAIT_SEC;
CONFIG.no_range_check = 0;
/*--------------- Cache related ---------------*/
CONFIG.cache_enabled = 0;

View File

@ -53,6 +53,8 @@ typedef struct {
char *user_agent;
/** \brief The waiting time after getting HTTP 429 (too many requests) */
int http_wait_sec;
/** \brief Disable check for the server's support of HTTP range request */
int no_range_check;
/** \brief Whether cache mode is enabled */
int cache_enabled;