summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Gupta <ashmew2@gmail.com>2017-05-11 16:59:45 (GMT)
committer Ashish Gupta <ashmew2@gmail.com>2017-06-10 06:25:29 (GMT)
commitdac20745dc4f069267cca761fdebb3c62f3b79f6 (patch)
tree5062020fd574a316e7730225db98ebd19baa9fed
parent839c2e8e6342dae087b73812ffeffda47af2094a (diff)
downloadnetsurf-dac20745dc4f069267cca761fdebb3c62f3b79f6.tar.gz
netsurf-dac20745dc4f069267cca761fdebb3c62f3b79f6.tar.bz2
Do multiple FETCH_DATA callbacks from http fetcher instead of just one large callback
-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 6800cab..3361b04 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);