summaryrefslogtreecommitdiff
path: root/src/cache/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache/handlers')
-rw-r--r--src/cache/handlers/http.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c
index 308633e..b5f2504 100644
--- a/src/cache/handlers/http.c
+++ b/src/cache/handlers/http.c
@@ -16,36 +16,41 @@ static bool handler_http_can_seek(struct cch_handler *handler)
return false;
}
-static size_t http_callback(void *userdata, u8 op, u8 *buf, s64 int0)
+static void http_callback(void *userdata, u8 op, u8 *buf, void *opaque)
{
struct cch_handler_http *http = (struct cch_handler_http *)userdata;
- size_t ret = (size_t)int0;
switch (op) {
case NNWT_HTTP_READ:
- al_assert_and_return(0);
+ al_assert(false);
case NNWT_HTTP_WRITE: {
+ size_t n = *(size_t *)opaque;
// If we got data before a Content-Length, assume the size is unknown.
if (cch_entry_get_size(http->handler.entry) < 0) {
cch_entry_set_size(http->handler.entry, 0);
}
- http->backing->write(http->backing, buf, http->pointer, &ret);
- http->pointer += ret;
+ http->backing->write(http->backing, buf, http->pointer, &n);
+ http->pointer += n;
+ *(size_t *)opaque = n;
cch_threaded_waits_evaluate(&http->handler, http->backing);
break;
}
- case NNWT_HTTP_RESPONSE_CODE:
- al_log_debug("cache_handler_http", "HTTP %ld.", int0);
+ case NNWT_HTTP_RESPONSE_CODE: {
+ long response_code = *(long *)opaque;
+ al_log_debug("cache_handler_http", "HTTP %ld.", response_code);
break;
+ }
case NNWT_HTTP_CONTENT_LENGTH: {
- off_t content_length = (off_t)int0;
- al_log_debug("cache_handler_http", "Content-Length: %lld.", content_length);
- cch_entry_set_size(http->handler.entry, content_length);
+ curl_off_t length = *(curl_off_t *)opaque;
+ al_log_debug("cache_handler_http", "Content-Length: %lld.", length);
+ cch_entry_set_size(http->handler.entry, length);
cch_threaded_waits_signal_any(&http->handler);
break;
}
- case NNWT_HTTP_REDIRECT:
- al_log_debug("cache_handler_http", "Redirect %ld.", int0);
+ case NNWT_HTTP_REDIRECT: {
+ long response_code = *(long *)opaque;
+ al_log_debug("cache_handler_http", "Redirect %ld.", response_code);
break;
+ }
case NNWT_HTTP_FINISHED:
al_log_debug("cache_handler_http", "Transfer finished.");
break;
@@ -55,7 +60,6 @@ static size_t http_callback(void *userdata, u8 op, u8 *buf, s64 int0)
default:
break;
}
- return ret;
}
static void handler_http_maybe_spawn_worker(struct cch_handler *handler, size_t index)