Fix extra compiler warnings
[project/uclient.git] / uclient-http.c
index ebe77582368ebee4f7a50482f49b154b12371b16..279669620ebe659b5904d6e3275b991e40f1e700 100644 (file)
@@ -149,7 +149,8 @@ static void uclient_http_disconnect(struct uclient_http *uh)
        if (uh->ssl)
                ustream_free(&uh->ussl.stream);
        ustream_free(&uh->ufd.stream);
-       close(uh->ufd.fd.fd);
+       if(uh->ufd.fd.fd)
+               close(uh->ufd.fd.fd);
        uh->us = NULL;
 }
 
@@ -198,7 +199,8 @@ static void uclient_notify_eof(struct uclient_http *uh)
                        return;
        }
 
-       if (uh->content_length < 0 && uh->read_chunked >= 0)
+       if ((uh->content_length < 0 && uh->read_chunked >= 0) ||
+                       uh->content_length == 0)
                uh->uc.data_eof = true;
 
        uclient_backend_set_eof(&uh->uc);
@@ -594,7 +596,8 @@ uclient_http_send_headers(struct uclient_http *uh)
        struct blob_attr *cur;
        enum request_type req_type = uh->req_type;
        bool literal_ipv6;
-       int err, rem;
+       int err;
+       size_t rem;
 
        if (uh->state >= HTTP_STATE_HEADERS_SENT)
                return 0;
@@ -980,7 +983,7 @@ int
 uclient_http_set_request_type(struct uclient *cl, const char *type)
 {
        struct uclient_http *uh = container_of(cl, struct uclient_http, uc);
-       int i;
+       unsigned int i;
 
        if (cl->backend != &uclient_backend_http)
                return -1;
@@ -1173,8 +1176,15 @@ int uclient_http_redirect(struct uclient *cl)
        if (!url)
                return false;
 
-       free(cl->url);
-       cl->url = url;
+       if (cl->proxy_url) {
+               free(cl->proxy_url);
+               cl->proxy_url = url;
+       }
+       else {
+               free(cl->url);
+               cl->url = url;
+       }
+
        if (uclient_http_connect(cl))
                return -1;