diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-03-22 18:30:09 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-03-22 18:30:09 +0100 |
commit | dbd61a7a6d5b61ba24d73f56e97b4d56baedffaf (patch) | |
tree | 18094eb1f5baa30597d082a8a8561b7ae1b5dae9 /uclient-http.c | |
parent | 6ee437e845ad57a8f86dc4f3fbbaddfd487de059 (diff) | |
download | uclient-dbd61a7a6d5b61ba24d73f56e97b4d56baedffaf.tar.gz |
parse the http response code
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-http.c')
-rw-r--r-- | uclient-http.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/uclient-http.c b/uclient-http.c index c344513..ef44a40 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -501,6 +501,19 @@ static void uclient_parse_http_line(struct uclient_http *uh, char *data) char *sep; if (uh->state == HTTP_STATE_REQUEST_DONE) { + char *code; + + /* HTTP/1.1 */ + strsep(&data, " "); + + code = strsep(&data, " "); + if (!code) + goto error; + + uh->uc.status_code = strtoul(code, &sep, 10); + if (sep && *sep) + goto error; + uh->state = HTTP_STATE_RECV_HEADERS; return; } @@ -524,6 +537,12 @@ static void uclient_parse_http_line(struct uclient_http *uh, char *data) sep++; blobmsg_add_string(&uh->meta, name, sep); + return; + +error: + uh->uc.status_code = 400; + uh->eof = true; + uclient_notify_eof(uh); } static void __uclient_notify_read(struct uclient_http *uh) |