Changes in / [ef2ecec:4f086417] in mainline


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

Legend:

Unmodified
Added
Removed
  • uspace/app/download/Makefile

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

    ref2ecec r4f086417  
    4747#include <net/socket.h>
    4848
    49 #include <http.h>
     49#include <http/http.h>
    5050#include <uri.h>
    5151
     
    132132                fprintf(stderr, "Failed creating request\n");
    133133                uri_destroy(uri);
    134                 free(server_path);
    135134                return 3;
    136135        }
    137136       
    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);
     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        }
    155150       
    156151        http_t *http = http_create(uri->host, port);
    157152        if (http == NULL) {
    158153                uri_destroy(uri);
    159                 free(server_path);
    160154                fprintf(stderr, "Failed creating HTTP object\n");
    161155                return 3;
    162156        }
    163157       
    164         int rc = http_connect(http);
     158        rc = http_connect(http);
    165159        if (rc != EOK) {
    166160                fprintf(stderr, "Failed connecting: %s\n", str_error(rc));
    167161                uri_destroy(uri);
    168                 free(server_path);
    169162                return rc;
    170163        }
     
    174167                fprintf(stderr, "Failed sending request: %s\n", str_error(rc));
    175168                uri_destroy(uri);
    176                 free(server_path);
    177169                return rc;
    178170        }
    179171       
    180172        http_response_t *response = NULL;
    181         rc = http_receive_response(http, &response);
     173        rc = http_receive_response(&http->recv_buffer, &response, 16 * 1024,
     174            100);
    182175        if (rc != EOK) {
    183176                fprintf(stderr, "Failed receiving response: %s\n", str_error(rc));
    184177                uri_destroy(uri);
    185                 free(server_path);
    186178                return rc;
    187179        }
     
    197189                        fprintf(stderr, "Failed allocating buffer\n)");
    198190                        uri_destroy(uri);
    199                         free(server_path);
    200191                        return ENOMEM;
    201192                }
    202193               
    203194                int body_size;
    204                 while ((body_size = http_receive_body(http, buf, buf_size)) > 0) {
     195                while ((body_size = recv_buffer(&http->recv_buffer, buf, buf_size)) > 0) {
    205196                        fwrite(buf, 1, body_size, stdout);
    206197                }
     
    212203       
    213204        uri_destroy(uri);
    214         free(server_path);
    215205        return EOK;
    216206}
  • uspace/lib/http/Makefile

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