projects
/
project
/
uclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add missing prototype for uclient_backend_set_error
[project/uclient.git]
/
uclient-http.c
diff --git
a/uclient-http.c
b/uclient-http.c
index
c3d1d5a
..
b6f28e1
100644
(file)
--- 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 *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;
}
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);
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)
}
static void __uclient_notify_read(struct uclient_http *uh)
@@
-741,7
+760,8
@@
uclient_http_send_data(struct uclient *cl, char *buf, unsigned int len)
uclient_http_send_headers(uh);
ustream_printf(uh->us, "%X\r\n", len);
uclient_http_send_headers(uh);
ustream_printf(uh->us, "%X\r\n", len);
- ustream_write(uh->us, buf, len, false);
+ if (len > 0)
+ ustream_write(uh->us, buf, len, false);
ustream_printf(uh->us, "\r\n");
return len;
ustream_printf(uh->us, "\r\n");
return len;
@@
-830,7
+850,7
@@
uclient_http_read(struct uclient *cl, char *buf, unsigned int len)
return len;
}
return len;
}
-const struct uclient_backend uclient_backend_http
__hidden
= {
+const struct uclient_backend uclient_backend_http = {
.prefix = uclient_http_prefix,
.alloc = uclient_http_alloc,
.prefix = uclient_http_prefix,
.alloc = uclient_http_alloc,