X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuclient.git;a=blobdiff_plain;f=uclient-http.c;h=9f9fac94be27aa366aa5d9ea0390909d8dbf1dd4;hp=7c5bc63c37160212374a529432f5420b30e610c8;hb=8d8c2e64db8c1e9f39bf79028da7f59fb33767f3;hpb=57a1dda8f31878282e554bb98d5cc81307edea49 diff --git a/uclient-http.c b/uclient-http.c index 7c5bc63..9f9fac9 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -319,6 +319,22 @@ static char *digest_unquote_sep(char **str) return start; } +static char *digest_sep(char **str) +{ + char *cur, *next; + + cur = *str; + next = strchr(*str, ','); + if (next) { + *str = next + 1; + *next = 0; + } else { + *str += strlen(*str); + } + + return cur; +} + static bool strmatch(char **str, const char *prefix) { int len = strlen(prefix); @@ -413,8 +429,9 @@ uclient_http_add_auth_digest(struct uclient_http *uh) next = buf; while (*next) { const char **dest = NULL; + const char *tmp; - while (isspace(*next)) + while (*next && isspace(*next)) next++; if (strmatch(&next, "realm")) @@ -425,8 +442,18 @@ uclient_http_add_auth_digest(struct uclient_http *uh) dest = &data.nonce; else if (strmatch(&next, "opaque")) dest = &opaque; - else - return; + else if (strmatch(&next, "stale") || + strmatch(&next, "algorithm") || + strmatch(&next, "auth-param")) { + digest_sep(&next); + continue; + } else if (strmatch(&next, "domain") || + strmatch(&next, "qop-options")) + dest = &tmp; + else { + digest_sep(&next); + continue; + } *dest = digest_unquote_sep(&next); } @@ -662,8 +689,13 @@ static void __uclient_notify_read(struct uclient_http *uh) if (uh->eof) return; - if (uh->state == HTTP_STATE_RECV_DATA && uc->cb->data_read) - uc->cb->data_read(uc); + if (uh->state == HTTP_STATE_RECV_DATA) { + /* Now it's uclient user turn to read some data */ + uloop_timeout_cancel(&uc->connection_timeout); + + if (uc->cb->data_read) + uc->cb->data_read(uc); + } } static void __uclient_notify_write(struct uclient_http *uh) @@ -899,7 +931,7 @@ uclient_http_set_header(struct uclient *cl, const char *name, const char *value) } static int -uclient_http_send_data(struct uclient *cl, char *buf, unsigned int len) +uclient_http_send_data(struct uclient *cl, const char *buf, unsigned int len) { struct uclient_http *uh = container_of(cl, struct uclient_http, uc); @@ -1003,6 +1035,10 @@ uclient_http_read(struct uclient *cl, char *buf, unsigned int len) uclient_notify_eof(uh); + /* Now that we consumed something and if this isn't EOF, start timer again */ + if (!uh->uc.eof && !cl->connection_timeout.pending) + uloop_timeout_set(&cl->connection_timeout, cl->timeout_msecs); + return len; }