http.c (251001) | http.c (256257) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2000-2011 Dag-Erling Sm��rgrav | 2 * Copyright (c) 2000-2013 Dag-Erling 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 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. --- 11 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> | 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 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. --- 11 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: stable/9/lib/libfetch/http.c 251001 2013-05-26 16:48:51Z des $"); | 30__FBSDID("$FreeBSD: stable/9/lib/libfetch/http.c 256257 2013-10-10 09:42:41Z glebius $"); |
31 32/* 33 * The following copyright applies to the base64 code: 34 * 35 *- 36 * Copyright 1997 Massachusetts Institute of Technology 37 * 38 * Permission to use, copy, modify, and distribute this software and --- 1356 unchanged lines hidden (view full) --- 1395 curl = (purl != NULL) ? purl : URL; 1396 1397 if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) 1398 /* fetch_connect() has already set an error code */ 1399 return (NULL); 1400 if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && purl) { 1401 http_cmd(conn, "CONNECT %s:%d HTTP/1.1", 1402 URL->host, URL->port); | 31 32/* 33 * The following copyright applies to the base64 code: 34 * 35 *- 36 * Copyright 1997 Massachusetts Institute of Technology 37 * 38 * Permission to use, copy, modify, and distribute this software and --- 1356 unchanged lines hidden (view full) --- 1395 curl = (purl != NULL) ? purl : URL; 1396 1397 if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) 1398 /* fetch_connect() has already set an error code */ 1399 return (NULL); 1400 if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && purl) { 1401 http_cmd(conn, "CONNECT %s:%d HTTP/1.1", 1402 URL->host, URL->port); |
1403 http_cmd(conn, "Host: %s:%d", 1404 URL->host, URL->port); |
|
1403 http_cmd(conn, ""); 1404 if (http_get_reply(conn) != HTTP_OK) { 1405 fetch_close(conn); 1406 return (NULL); 1407 } 1408 http_get_reply(conn); 1409 } 1410 if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && | 1405 http_cmd(conn, ""); 1406 if (http_get_reply(conn) != HTTP_OK) { 1407 fetch_close(conn); 1408 return (NULL); 1409 } 1410 http_get_reply(conn); 1411 } 1412 if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && |
1411 fetch_ssl(conn, verbose) == -1) { | 1413 fetch_ssl(conn, URL, verbose) == -1) { |
1412 fetch_close(conn); 1413 /* grrr */ 1414 errno = EAUTH; 1415 fetch_syserr(); 1416 return (NULL); 1417 } 1418 1419 val = 1; --- 156 unchanged lines hidden (view full) --- 1576 snprintf(hbuf + strlen(hbuf), 1577 sizeof(hbuf) - strlen(hbuf), ":%d", url->port); 1578 } 1579 1580 /* send request */ 1581 if (verbose) 1582 fetch_info("requesting %s://%s%s", 1583 url->scheme, host, url->doc); | 1414 fetch_close(conn); 1415 /* grrr */ 1416 errno = EAUTH; 1417 fetch_syserr(); 1418 return (NULL); 1419 } 1420 1421 val = 1; --- 156 unchanged lines hidden (view full) --- 1578 snprintf(hbuf + strlen(hbuf), 1579 sizeof(hbuf) - strlen(hbuf), ":%d", url->port); 1580 } 1581 1582 /* send request */ 1583 if (verbose) 1584 fetch_info("requesting %s://%s%s", 1585 url->scheme, host, url->doc); |
1584 if (purl) { | 1586 if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) { |
1585 http_cmd(conn, "%s %s://%s%s HTTP/1.1", 1586 op, url->scheme, host, url->doc); 1587 } else { 1588 http_cmd(conn, "%s %s HTTP/1.1", 1589 op, url->doc); 1590 } 1591 1592 if (ims && url->ims_time) { --- 66 unchanged lines hidden (view full) --- 1659 goto ouch; 1660 } 1661 http_authorize(conn, "Authorization", 1662 &server_challenges, &aparams, url); 1663 clean_http_auth_params(&aparams); 1664 } 1665 1666 /* other headers */ | 1587 http_cmd(conn, "%s %s://%s%s HTTP/1.1", 1588 op, url->scheme, host, url->doc); 1589 } else { 1590 http_cmd(conn, "%s %s HTTP/1.1", 1591 op, url->doc); 1592 } 1593 1594 if (ims && url->ims_time) { --- 66 unchanged lines hidden (view full) --- 1661 goto ouch; 1662 } 1663 http_authorize(conn, "Authorization", 1664 &server_challenges, &aparams, url); 1665 clean_http_auth_params(&aparams); 1666 } 1667 1668 /* other headers */ |
1669 if ((p = getenv("HTTP_ACCEPT")) != NULL) { 1670 if (*p != '\0') 1671 http_cmd(conn, "Accept: %s", p); 1672 } else { 1673 http_cmd(conn, "Accept: */*"); 1674 } |
|
1667 if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') { 1668 if (strcasecmp(p, "auto") == 0) 1669 http_cmd(conn, "Referer: %s://%s%s", 1670 url->scheme, host, url->doc); 1671 else 1672 http_cmd(conn, "Referer: %s", p); 1673 } 1674 if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0') --- 358 unchanged lines hidden --- | 1675 if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') { 1676 if (strcasecmp(p, "auto") == 0) 1677 http_cmd(conn, "Referer: %s://%s%s", 1678 url->scheme, host, url->doc); 1679 else 1680 http_cmd(conn, "Referer: %s", p); 1681 } 1682 if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0') --- 358 unchanged lines hidden --- |