http.c (97891) | http.c (98422) |
---|---|
1/*- 2 * Copyright (c) 2000 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 --- 13 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> | 1/*- 2 * Copyright (c) 2000 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 --- 13 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: head/lib/libfetch/http.c 97891 2002-06-05 21:35:35Z des $"); | 30__FBSDID("$FreeBSD: head/lib/libfetch/http.c 98422 2002-06-19 08:36:00Z des $"); |
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 --- 722 unchanged lines hidden (view full) --- 761 */ 762FILE * 763_http_request(struct url *URL, const char *op, struct url_stat *us, 764 struct url *purl, const char *flags) 765{ 766 conn_t *conn; 767 struct url *url, *new; 768 int chunked, direct, need_auth, noredirect, verbose; | 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 --- 722 unchanged lines hidden (view full) --- 761 */ 762FILE * 763_http_request(struct url *URL, const char *op, struct url_stat *us, 764 struct url *purl, const char *flags) 765{ 766 conn_t *conn; 767 struct url *url, *new; 768 int chunked, direct, need_auth, noredirect, verbose; |
769 int i, n; | 769 int e, i, n; |
770 off_t offset, clength, length, size; 771 time_t mtime; 772 const char *p; 773 FILE *f; 774 hdr_t h; 775 char *host; 776#ifdef INET6 777 char hbuf[MAXHOSTNAMELEN + 1]; --- 10 unchanged lines hidden (view full) --- 788 789 /* try the provided URL first */ 790 url = URL; 791 792 /* if the A flag is set, we only get one try */ 793 n = noredirect ? 1 : MAX_REDIRECT; 794 i = 0; 795 | 770 off_t offset, clength, length, size; 771 time_t mtime; 772 const char *p; 773 FILE *f; 774 hdr_t h; 775 char *host; 776#ifdef INET6 777 char hbuf[MAXHOSTNAMELEN + 1]; --- 10 unchanged lines hidden (view full) --- 788 789 /* try the provided URL first */ 790 url = URL; 791 792 /* if the A flag is set, we only get one try */ 793 n = noredirect ? 1 : MAX_REDIRECT; 794 i = 0; 795 |
796 e = HTTP_PROTOCOL_ERROR; |
|
796 need_auth = 0; 797 do { 798 new = NULL; 799 chunked = 0; 800 offset = 0; 801 clength = -1; 802 length = -1; 803 size = -1; --- 181 unchanged lines hidden (view full) --- 985 } while (h > hdr_end); 986 987 /* we have a hit or an error */ 988 if (conn->err == HTTP_OK || conn->err == HTTP_PARTIAL || HTTP_ERROR(conn->err)) 989 break; 990 991 /* we need to provide authentication */ 992 if (conn->err == HTTP_NEED_AUTH) { | 797 need_auth = 0; 798 do { 799 new = NULL; 800 chunked = 0; 801 offset = 0; 802 clength = -1; 803 length = -1; 804 size = -1; --- 181 unchanged lines hidden (view full) --- 986 } while (h > hdr_end); 987 988 /* we have a hit or an error */ 989 if (conn->err == HTTP_OK || conn->err == HTTP_PARTIAL || HTTP_ERROR(conn->err)) 990 break; 991 992 /* we need to provide authentication */ 993 if (conn->err == HTTP_NEED_AUTH) { |
994 e = conn->err; |
|
993 need_auth = 1; 994 _fetch_close(conn); 995 conn = NULL; 996 continue; 997 } 998 999 /* all other cases: we got a redirect */ | 995 need_auth = 1; 996 _fetch_close(conn); 997 conn = NULL; 998 continue; 999 } 1000 1001 /* all other cases: we got a redirect */ |
1002 e = conn->err; |
|
1000 need_auth = 0; 1001 _fetch_close(conn); 1002 conn = NULL; 1003 if (!new) { 1004 DEBUG(fprintf(stderr, "redirect with no new location\n")); 1005 break; 1006 } 1007 if (url != URL) 1008 fetchFreeURL(url); 1009 url = new; 1010 } while (++i < n); 1011 1012 /* we failed, or ran out of retries */ 1013 if (conn == NULL) { | 1003 need_auth = 0; 1004 _fetch_close(conn); 1005 conn = NULL; 1006 if (!new) { 1007 DEBUG(fprintf(stderr, "redirect with no new location\n")); 1008 break; 1009 } 1010 if (url != URL) 1011 fetchFreeURL(url); 1012 url = new; 1013 } while (++i < n); 1014 1015 /* we failed, or ran out of retries */ 1016 if (conn == NULL) { |
1014 _http_seterr(conn->err); | 1017 _http_seterr(e); |
1015 goto ouch; 1016 } 1017 1018 DEBUG(fprintf(stderr, "offset %lld, length %lld," 1019 " size %lld, clength %lld\n", 1020 (long long)offset, (long long)length, 1021 (long long)size, (long long)clength)); 1022 --- 117 unchanged lines hidden --- | 1018 goto ouch; 1019 } 1020 1021 DEBUG(fprintf(stderr, "offset %lld, length %lld," 1022 " size %lld, clength %lld\n", 1023 (long long)offset, (long long)length, 1024 (long long)size, (long long)clength)); 1025 --- 117 unchanged lines hidden --- |