Fix unused results warnings
[project/uclient.git] / uclient-http.c
index f0451cc805b7c65eb70553616198838935ee3570..ac9d50f4b2ad914590bf6517f4fe90b181f7425a 100644 (file)
@@ -379,11 +379,14 @@ get_cnonce(char *dest)
 {
        uint32_t val = 0;
        FILE *f;
+       size_t n;
 
        f = fopen("/dev/urandom", "r");
        if (f) {
-               fread(&val, sizeof(val), 1, f);
+               n = fread(&val, sizeof(val), 1, f);
                fclose(f);
+               if (n != 1)
+                       return;
        }
 
        bin_to_hex(dest, &val, sizeof(val));
@@ -569,9 +572,11 @@ uclient_http_send_headers(struct uclient_http *uh)
 
        ustream_printf(uh->us,
                "%s %s HTTP/1.1\r\n"
-               "Host: %s\r\n",
+               "Host: %s%s%s\r\n",
                request_types[req_type],
-               url->location, url->host);
+               url->location, url->host,
+               url->port ? ":" : "",
+               url->port ? url->port : "");
 
        blobmsg_for_each_attr(cur, uh->headers.head, rem)
                ustream_printf(uh->us, "%s: %s\r\n", blobmsg_name(cur), (char *) blobmsg_data(cur));
@@ -1114,7 +1119,7 @@ int uclient_http_redirect(struct uclient *cl)
        if (!tb)
                return false;
 
-       url = uclient_get_url(blobmsg_data(tb), url->auth);
+       url = uclient_get_url_location(url, blobmsg_data(tb));
        if (!url)
                return false;