Changes in / [c42f50d:3e896e1] in mainline
- Location:
- uspace
- Files:
-
- 2 added
- 9 deleted
- 3 edited
-
app/download/Makefile (modified) (1 diff)
-
app/download/main.c (modified) (5 diffs)
-
lib/http/Makefile (modified) (1 diff)
-
lib/http/http.c (added)
-
lib/http/http.h (added)
-
lib/http/include/http/ctype.h (deleted)
-
lib/http/include/http/errno.h (deleted)
-
lib/http/include/http/http.h (deleted)
-
lib/http/include/http/receive-buffer.h (deleted)
-
lib/http/src/headers.c (deleted)
-
lib/http/src/http.c (deleted)
-
lib/http/src/receive-buffer.c (deleted)
-
lib/http/src/request.c (deleted)
-
lib/http/src/response.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/download/Makefile
rc42f50d r3e896e1 29 29 USPACE_PREFIX = ../.. 30 30 LIBS = $(LIBHTTP_PREFIX)/libhttp.a $(LIBURI_PREFIX)/liburi.a 31 EXTRA_CFLAGS = -I$(LIBHTTP_PREFIX) /include-I$(LIBURI_PREFIX)31 EXTRA_CFLAGS = -I$(LIBHTTP_PREFIX) -I$(LIBURI_PREFIX) 32 32 DEFS = -DRELEASE=$(RELEASE) 33 33 BINARY = download -
uspace/app/download/main.c
rc42f50d r3e896e1 47 47 #include <net/socket.h> 48 48 49 #include <http /http.h>49 #include <http.h> 50 50 #include <uri.h> 51 51 … … 132 132 fprintf(stderr, "Failed creating request\n"); 133 133 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); 150 155 151 156 http_t *http = http_create(uri->host, port); 152 157 if (http == NULL) { 153 158 uri_destroy(uri); 159 free(server_path); 154 160 fprintf(stderr, "Failed creating HTTP object\n"); 155 161 return 3; 156 162 } 157 163 158 rc = http_connect(http);164 int rc = http_connect(http); 159 165 if (rc != EOK) { 160 166 fprintf(stderr, "Failed connecting: %s\n", str_error(rc)); 161 167 uri_destroy(uri); 168 free(server_path); 162 169 return rc; 163 170 } … … 167 174 fprintf(stderr, "Failed sending request: %s\n", str_error(rc)); 168 175 uri_destroy(uri); 176 free(server_path); 169 177 return rc; 170 178 } 171 179 172 180 http_response_t *response = NULL; 173 rc = http_receive_response( &http->recv_buffer, &response);181 rc = http_receive_response(http, &response); 174 182 if (rc != EOK) { 175 183 fprintf(stderr, "Failed receiving response: %s\n", str_error(rc)); 176 184 uri_destroy(uri); 185 free(server_path); 177 186 return rc; 178 187 } … … 188 197 fprintf(stderr, "Failed allocating buffer\n)"); 189 198 uri_destroy(uri); 199 free(server_path); 190 200 return ENOMEM; 191 201 } 192 202 193 203 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) { 195 205 fwrite(buf, 1, body_size, stdout); 196 206 } … … 202 212 203 213 uri_destroy(uri); 214 free(server_path); 204 215 return EOK; 205 216 } -
uspace/lib/http/Makefile
rc42f50d r3e896e1 31 31 SLIBRARY = libhttp.so.0.0 32 32 LSONAME = libhttp.so0 33 EXTRA_CFLAGS += -Iinclude 33 #EXTRA_CFLAGS += 34 34 35 35 SOURCES = \ 36 src/http.c \ 37 src/headers.c \ 38 src/request.c \ 39 src/response.c \ 40 src/receive-buffer.c 36 http.c 41 37 42 38 include $(USPACE_PREFIX)/Makefile.common
Note:
See TracChangeset
for help on using the changeset viewer.
