summaryrefslogtreecommitdiff
path: root/content/fetchers
diff options
context:
space:
mode:
Diffstat (limited to 'content/fetchers')
-rw-r--r--content/fetchers/httplib_kolibri.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/content/fetchers/httplib_kolibri.c b/content/fetchers/httplib_kolibri.c
index 6800cab13..3361b0460 100644
--- a/content/fetchers/httplib_kolibri.c
+++ b/content/fetchers/httplib_kolibri.c
@@ -21,6 +21,7 @@ struct httpfetcher {
struct http_msg *handle;
struct fetch *owner;
bool headercbdone;
+ unsigned int datalen_cb_done;
struct httpfetcher *next;
};
@@ -98,7 +99,7 @@ bool init_fetcher(lwc_string *scheme) {
return supported_scheme;
}
-
+
bool supported_url_check(const struct nsurl *url) {
bool supported;
lwc_string *url_scheme = nsurl_get_component(url, NSURL_SCHEME);
@@ -156,6 +157,7 @@ void *setup_fetch(struct fetch *parent_fetch, struct nsurl *url,
newfetcher->handle = request;
newfetcher->headercbdone = false;
newfetcher->owner = parent_fetch;
+ newfetcher->datalen_cb_done = 0;
return newfetcher;
}
@@ -296,19 +298,36 @@ void poll_fetch(lwc_string *scheme) {
LOG("---- Headers not received yet.");
}
}
+ else if(ret == -1) {
+ /* If data was received send it to netsurf core with FETCH_DATA */
+ /* LOG("Doing a data callback; so far : %u vs %u!", t->datalen_cb_done, t->handle->content_received); */
+
+ if(t->handle->content_received > t->datalen_cb_done) {
+ fetch_msg msg;
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) (t->handle->content_ptr + t->datalen_cb_done);
+ msg.data.header_or_data.len = t->handle->content_received - t->datalen_cb_done;
+ fetch_send_callback(&msg, t->owner);
+ t->datalen_cb_done = t->handle->content_received;
+ }
+ }
else if(ret == 0) {
- fetch_msg msg;
- msg.type = FETCH_DATA;
- msg.data.header_or_data.buf = (const uint8_t *)t->handle->content_ptr;
- msg.data.header_or_data.len = t->handle->content_length;
- fetch_send_callback(&msg, t->owner);
-
- LOG("---- FETCH_FINISHED for fetch 0x%x", t->owner);
+ if(t->handle->content_received > t->datalen_cb_done) {
+ /* Callback any remaining data before finishing off */
+ fetch_msg msg;
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) (t->handle->content_ptr + t->datalen_cb_done);
+ msg.data.header_or_data.len = t->handle->content_received - t->datalen_cb_done;
+ fetch_send_callback(&msg, t->owner);
+ t->datalen_cb_done = t->handle->content_received;
+ }
+ fetch_msg msg;
msg.type = FETCH_FINISHED;
msg.data.header_or_data.buf = NULL;
msg.data.header_or_data.len = 0;
fetch_send_callback(&msg, t->owner);
+ LOG("---- FETCH_FINISHED for fetch 0x%x", t->owner);
struct httpfetcher *tnext = t->next;
remove_from_poll(t->handle);