Changeset 4d4f656 in mainline for uspace/app/download/main.c


Ignore:
Timestamp:
2013-09-26T20:50:52Z (11 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
408424e
Parents:
b623b68
Message:

libhttp: Add higher-level API for working with headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/download/main.c

    rb623b68 r4d4f656  
    135135        }
    136136       
    137         http_header_t *header_host = http_header_create("Host", uri->host);
    138         if (header_host == NULL) {
    139                 fprintf(stderr, "Failed creating Host header\n");
    140                 uri_destroy(uri);
    141                 return 3;
    142         }
    143         list_append(&header_host->link, &req->headers);
    144        
    145         http_header_t *header_ua = http_header_create("User-Agent", USER_AGENT);
    146         if (header_ua == NULL) {
    147                 fprintf(stderr, "Failed creating User-Agent header\n");
    148                 uri_destroy(uri);
    149                 return 3;
    150         }
    151         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        }
    152150       
    153151        http_t *http = http_create(uri->host, port);
     
    158156        }
    159157       
    160         int rc = http_connect(http);
     158        rc = http_connect(http);
    161159        if (rc != EOK) {
    162160                fprintf(stderr, "Failed connecting: %s\n", str_error(rc));
Note: See TracChangeset for help on using the changeset viewer.