+bool uclient_http_redirect(struct uclient *cl)
+{
+ struct uclient_http *uh = container_of(cl, struct uclient_http, uc);
+ struct blobmsg_policy location = {
+ .name = "location",
+ .type = BLOBMSG_TYPE_STRING,
+ };
+ struct uclient_url *url = cl->url;
+ struct blob_attr *tb;
+
+ if (cl->backend != &uclient_backend_http)
+ return false;
+
+ switch (cl->status_code) {
+ case 301:
+ case 302:
+ case 307:
+ break;
+ default:
+ return false;
+ }
+
+ blobmsg_parse(&location, 1, &tb, blob_data(uh->meta.head), blob_len(uh->meta.head));
+ if (!tb)
+ return false;
+
+ url = uclient_get_url(blobmsg_data(tb), url->auth);
+ if (!url)
+ return false;
+
+ free(cl->url);
+ cl->url = url;
+ uclient_http_connect(cl);
+ uclient_http_request_done(cl);
+
+ return true;
+}
+
+int uclient_http_set_ssl_ctx(struct uclient *cl, const struct ustream_ssl_ops *ops,
+ struct ustream_ssl_ctx *ctx, bool require_validation)
+{
+ struct uclient_http *uh = container_of(cl, struct uclient_http, uc);
+
+ if (cl->backend != &uclient_backend_http)
+ return -1;
+
+ uclient_http_free_url_state(cl);
+
+ uclient_http_free_ssl_ctx(uh);
+ uh->ssl_ops = ops;
+ uh->ssl_ctx = ctx;
+ uh->ssl_require_validation = !!ctx && require_validation;
+
+ return 0;
+}
+
+const struct uclient_backend uclient_backend_http = {