http.c (60581) | http.c (60587) |
---|---|
1/*- 2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/lib/libfetch/http.c 60581 2000-05-15 08:24:29Z des $ | 28 * $FreeBSD: head/lib/libfetch/http.c 60587 2000-05-15 09:05:36Z ume $ |
29 */ 30 31/* 32 * The base64 code in this file is based on code from MIT fetch, which 33 * has the following copyright and license: 34 * 35 *- 36 * Copyright 1997 Massachusetts Institute of Technology --- 269 unchanged lines hidden (view full) --- 306 307 direct = (flags && strchr(flags, 'd')); 308 verbose = (flags && strchr(flags, 'v')); 309 310 /* check port */ 311 if (!URL->port) { 312 struct servent *se; 313 | 29 */ 30 31/* 32 * The base64 code in this file is based on code from MIT fetch, which 33 * has the following copyright and license: 34 * 35 *- 36 * Copyright 1997 Massachusetts Institute of Technology --- 269 unchanged lines hidden (view full) --- 306 307 direct = (flags && strchr(flags, 'd')); 308 verbose = (flags && strchr(flags, 'v')); 309 310 /* check port */ 311 if (!URL->port) { 312 struct servent *se; 313 |
314 if ((se = getservbyname("http", "tcp")) != NULL) 315 URL->port = ntohs(se->s_port); | 314 if (strcasecmp(URL->scheme, "ftp") == 0) 315 if ((se = getservbyname("ftp", "tcp")) != NULL) 316 URL->port = ntohs(se->s_port); 317 else 318 URL->port = 21; |
316 else | 319 else |
317 URL->port = 80; | 320 if ((se = getservbyname("http", "tcp")) != NULL) 321 URL->port = ntohs(se->s_port); 322 else 323 URL->port = 80; |
318 } 319 320 /* attempt to connect to proxy server */ 321 if (!direct && (px = getenv("HTTP_PROXY")) != NULL) { 322 char host[MAXHOSTNAMELEN]; 323 int port = 0; 324 325 /* measure length */ --- 32 unchanged lines hidden (view full) --- 358 host[len] = 0; 359 360 /* connect */ 361 sd = _fetch_connect(host, port, verbose); 362 } 363 364 /* if no proxy is configured or could be contacted, try direct */ 365 if (sd == -1) { | 324 } 325 326 /* attempt to connect to proxy server */ 327 if (!direct && (px = getenv("HTTP_PROXY")) != NULL) { 328 char host[MAXHOSTNAMELEN]; 329 int port = 0; 330 331 /* measure length */ --- 32 unchanged lines hidden (view full) --- 364 host[len] = 0; 365 366 /* connect */ 367 sd = _fetch_connect(host, port, verbose); 368 } 369 370 /* if no proxy is configured or could be contacted, try direct */ 371 if (sd == -1) { |
372 if (strcasecmp(URL->scheme, "ftp") == 0) 373 goto ouch; |
|
366 if ((sd = _fetch_connect(URL->host, URL->port, verbose)) == -1) 367 goto ouch; 368 } 369 370 /* reopen as stream */ 371 if ((f = fdopen(sd, "r+")) == NULL) 372 goto ouch; 373 --- 15 unchanged lines hidden (view full) --- 389 int e, verbose; 390 char *ln, *p; 391 size_t len; 392 393 verbose = (flags && strchr(flags, 'v')); 394 395 /* send request (proxies require absolute form, so use that) */ 396 if (verbose) | 374 if ((sd = _fetch_connect(URL->host, URL->port, verbose)) == -1) 375 goto ouch; 376 } 377 378 /* reopen as stream */ 379 if ((f = fdopen(sd, "r+")) == NULL) 380 goto ouch; 381 --- 15 unchanged lines hidden (view full) --- 397 int e, verbose; 398 char *ln, *p; 399 size_t len; 400 401 verbose = (flags && strchr(flags, 'v')); 402 403 /* send request (proxies require absolute form, so use that) */ 404 if (verbose) |
397 _fetch_info("requesting http://%s:%d%s", 398 URL->host, URL->port, URL->doc); | 405 _fetch_info("requesting %s://%s:%d%s", 406 URL->scheme, URL->host, URL->port, URL->doc); |
399 _http_cmd(f, "%s %s://%s:%d%s HTTP/1.1" ENDL, 400 op, URL->scheme, URL->host, URL->port, URL->doc); 401 402 /* start sending headers away */ 403 if (URL->user[0] || URL->pwd[0]) { 404 char *auth_str = _http_auth(URL->user, URL->pwd); 405 if (!auth_str) 406 return 999; /* XXX wrong */ --- 218 unchanged lines hidden --- | 407 _http_cmd(f, "%s %s://%s:%d%s HTTP/1.1" ENDL, 408 op, URL->scheme, URL->host, URL->port, URL->doc); 409 410 /* start sending headers away */ 411 if (URL->user[0] || URL->pwd[0]) { 412 char *auth_str = _http_auth(URL->user, URL->pwd); 413 if (!auth_str) 414 return 999; /* XXX wrong */ --- 218 unchanged lines hidden --- |