Changes in / [c42f50d:3e896e1] in mainline


Ignore:
Location:
uspace
Files:
2 added
9 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/download/Makefile

    rc42f50d r3e896e1  
    2929USPACE_PREFIX = ../..
    3030LIBS = $(LIBHTTP_PREFIX)/libhttp.a $(LIBURI_PREFIX)/liburi.a
    31 EXTRA_CFLAGS = -I$(LIBHTTP_PREFIX)/include -I$(LIBURI_PREFIX)
     31EXTRA_CFLAGS = -I$(LIBHTTP_PREFIX) -I$(LIBURI_PREFIX)
    3232DEFS = -DRELEASE=$(RELEASE)
    3333BINARY = download
  • uspace/app/download/main.c

    rc42f50d r3e896e1  
    4747#include <net/socket.h>
    4848
    49 #include <http/http.h>
     49#include <http.h>
    5050#include <uri.h>
    5151
     
    132132                fprintf(stderr, "Failed creating request\n");
    133133                uri_destroy(uri);
    134                 return 3;
    135         }
    136        
    137         int rc = http_headers_append(&req->headers, "Host", uri->host);
    138         if (rc != EOK) {
    139                 fprintf(stderr, "Failed setting Host header: %s\n", str_error(rc));
    140                 uri_destroy(uri);
    141                 return rc;
    142         }
    143        
    144         rc = http_headers_append(&req->headers, "User-Agent", USER_AGENT);
    145         if (rc != EOK) {
    146                 fprintf(stderr, "Failed creating User-Agent header: %s\n", str_error(rc));
    147                 uri_destroy(uri);
    148                 return rc;
    149         }
     134                free(server_path);
     135                return 3;
     136        }
     137       
     138        http_header_t *header_host = http_header_create("Host", uri->host);
     139        if (header_host == NULL) {
     140                fprintf(stderr, "Failed creating Host header\n");
     141                uri_destroy(uri);
     142                free(server_path);
     143                return 3;
     144        }
     145        list_append(&header_host->link, &req->headers);
     146       
     147        http_header_t *header_ua = http_header_create("User-Agent", USER_AGENT);
     148        if (header_ua == NULL) {
     149                fprintf(stderr, "Failed creating User-Agent header\n");
     150                uri_destroy(uri);
     151                free(server_path);
     152                return 3;
     153        }
     154        list_append(&header_ua->link, &req->headers);
    150155       
    151156        http_t *http = http_create(uri->host, port);
    152157        if (http == NULL) {
    153158                uri_destroy(uri);
     159                free(server_path);
    154160                fprintf(stderr, "Failed creating HTTP object\n");
    155161                return 3;
    156162        }
    157163       
    158         rc = http_connect(http);
     164        int rc = http_connect(http);
    159165        if (rc != EOK) {
    160166                fprintf(stderr, "Failed connecting: %s\n", str_error(rc));
    161167                uri_destroy(uri);
     168                free(server_path);
    162169                return rc;
    163170        }
     
    167174                fprintf(stderr, "Failed sending request: %s\n", str_error(rc));
    168175                uri_destroy(uri);
     176                free(server_path);
    169177                return rc;
    170178        }
    171179       
    172180        http_response_t *response = NULL;
    173         rc = http_receive_response(&http->recv_buffer, &response);
     181        rc = http_receive_response(http, &response);
    174182        if (rc != EOK) {
    175183                fprintf(stderr, "Failed receiving response: %s\n", str_error(rc));
    176184                uri_destroy(uri);
     185                free(server_path);
    177186                return rc;
    178187        }
     
    188197                        fprintf(stderr, "Failed allocating buffer\n)");
    189198                        uri_destroy(uri);
     199                        free(server_path);
    190200                        return ENOMEM;
    191201                }
    192202               
    193203                int body_size;
    194                 while ((body_size = recv_buffer(&http->recv_buffer, buf, buf_size)) > 0) {
     204                while ((body_size = http_receive_body(http, buf, buf_size)) > 0) {
    195205                        fwrite(buf, 1, body_size, stdout);
    196206                }
     
    202212       
    203213        uri_destroy(uri);
     214        free(server_path);
    204215        return EOK;
    205216}
  • uspace/lib/http/Makefile

    rc42f50d r3e896e1  
    3131SLIBRARY = libhttp.so.0.0
    3232LSONAME = libhttp.so0
    33 EXTRA_CFLAGS += -Iinclude
     33#EXTRA_CFLAGS +=
    3434
    3535SOURCES = \
    36         src/http.c \
    37         src/headers.c \
    38         src/request.c \
    39         src/response.c \
    40         src/receive-buffer.c
     36        http.c
    4137
    4238include $(USPACE_PREFIX)/Makefile.common
Note: See TracChangeset for help on using the changeset viewer.