Support compression for GET responses

This commit is contained in:
wbaumann 2014-03-11 21:53:13 +00:00
parent 895527b357
commit c723d492d0
5 changed files with 28 additions and 2 deletions

View File

@ -1,9 +1,14 @@
ChangeLog for davfs2
--------------------

2014-03-11 Werner Baumann (werner.baumann@onlinehome.de)
* defaults.h, mount_davfs.h, mount_davfs.c, wedav.c:
Support compression for GET responses (bug #41355,
thanks Evili del Rio).

2014-03-09 Werner Baumann (werner.baumann@onlinehome.de)
* mount_davfs.c, get_options:
Add option "comment=" (bug #41354)
Add option "comment=" (bug #41354).

2013-09-08 Werner Baumann (werner.baumann@onlinehome.de)
* Updating to fuse kernel version 7.19.

View File

@ -174,6 +174,9 @@
May be overridden by system config file and user config file. */
#define DAV_IGNORE_DAV_HEADER 0

/* Use "Content-Encoding: gzip" for GET requests. */
#define DAV_USE_COMPRESSION 1

/* Timeout in seconds used when libneon supports non blocking io
A value of zero means use the TCP default
May be overriden by system config file and user config file. */

View File

@ -1607,6 +1607,7 @@ new_args(void)
args->allow_cookie = DAV_ALLOW_COOKIE;
args->precheck = DAV_PRECHECK;
args->ignore_dav_header = DAV_IGNORE_DAV_HEADER;
args->use_compression = DAV_USE_COMPRESSION;
args->connect_timeout = DAV_CONNECT_TIMEOUT;
args->read_timeout = DAV_READ_TIMEOUT;
args->retry = DAV_RETRY;
@ -2092,6 +2093,8 @@ read_config(dav_args *args, const char * filename, int system)
args->precheck = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "ignore_dav_header") == 0) {
args->ignore_dav_header = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "use_compression") == 0) {
args->use_compression = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "connect_timeout") == 0) {
args->connect_timeout = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "read_timeout") == 0) {

View File

@ -91,6 +91,7 @@ typedef struct {
int allow_cookie; /* User config file, system config file */
int precheck; /* User config file, system config file */
int ignore_dav_header; /* User config file, system config file */
int use_compression; /* User config file, system config file */
time_t connect_timeout; /* User config file, system config file */
time_t read_timeout; /* User config file, system config file */
time_t retry; /* User config file, system config file */

View File

@ -62,6 +62,7 @@

#include <ne_auth.h>
#include <ne_basic.h>
#include <ne_compress.h>
#include <ne_dates.h>
#include <ne_locks.h>
#include <ne_props.h>
@ -198,6 +199,9 @@ static int precheck;
/* Ignore the information in the DAV-header because it is wrong. */
static int ignore_dav_header;

/* Use "Content-Encoding: gzip" for GET requests. */
static int use_compression;

/* Will be set to 1 when dav_init_connection() succeeded. */
static int initialized;

@ -422,6 +426,7 @@ dav_init_webdav(dav_args *args)
drop_weak_etags = args->drop_weak_etags;
precheck = args->precheck;
ignore_dav_header = args->ignore_dav_header;
use_compression = args->use_compression & ne_has_support(NE_FEATURE_ZLIB);
}


@ -669,9 +674,18 @@ dav_get_file(const char *path, const char *cache_path, off_t *size,
ne_add_request_header(req, "If-Modified-Since", mod_time);
}

ne_add_response_body_reader(req, ne_accept_2xx, file_reader, &ctx);
ne_decompress *dc_state = NULL;
if (use_compression) {
dc_state = ne_decompress_reader(req, ne_accept_2xx, file_reader, &ctx);
} else {
ne_add_response_body_reader(req, ne_accept_2xx, file_reader, &ctx);
}

ret = ne_request_dispatch(req);

if (use_compression)
ne_decompress_destroy(dc_state);

ret = get_error(ret, "GET");
if (ctx.error)
ret = ctx.error;