Deleted Added
full compact
http.c (141958) http.c (143049)
1/*-
2 * Copyright (c) 2000-2004 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-2004 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 141958 2005-02-16 00:22:20Z kbyanc $");
30__FBSDID("$FreeBSD: head/lib/libfetch/http.c 143049 2005-03-02 19:09:28Z kbyanc $");
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

--- 748 unchanged lines hidden (view full) ---

787 */
788FILE *
789_http_request(struct url *URL, const char *op, struct url_stat *us,
790 struct url *purl, const char *flags)
791{
792 conn_t *conn;
793 struct url *url, *new;
794 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

--- 748 unchanged lines hidden (view full) ---

787 */
788FILE *
789_http_request(struct url *URL, const char *op, struct url_stat *us,
790 struct url *purl, const char *flags)
791{
792 conn_t *conn;
793 struct url *url, *new;
794 int chunked, direct, need_auth, noredirect, verbose;
795 int e, i, n;
795 int e, i, n, val;
796 off_t offset, clength, length, size;
797 time_t mtime;
798 const char *p;
799 FILE *f;
800 hdr_t h;
801 char hbuf[MAXHOSTNAMELEN + 7], *host;
802
803 direct = CHECK_FLAG('d');

--- 104 unchanged lines hidden (view full) ---

908 if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
909 _http_cmd(conn, "User-Agent: %s", p);
910 else
911 _http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
912 if (url->offset > 0)
913 _http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
914 _http_cmd(conn, "Connection: close");
915 _http_cmd(conn, "");
796 off_t offset, clength, length, size;
797 time_t mtime;
798 const char *p;
799 FILE *f;
800 hdr_t h;
801 char hbuf[MAXHOSTNAMELEN + 7], *host;
802
803 direct = CHECK_FLAG('d');

--- 104 unchanged lines hidden (view full) ---

908 if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
909 _http_cmd(conn, "User-Agent: %s", p);
910 else
911 _http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
912 if (url->offset > 0)
913 _http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
914 _http_cmd(conn, "Connection: close");
915 _http_cmd(conn, "");
916 shutdown(conn->sd, SHUT_WR);
917
916
917 /*
918 * Force the queued request to be dispatched. Normally, one
919 * would do this with shutdown(2) but squid proxies can be
920 * configured to disallow such half-closed connections. To
921 * be compatible with such configurations, fiddle with socket
922 * options to force the pending data to be written.
923 */
924 val = 0;
925 setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val,
926 sizeof(val));
927 val = 1;
928 setsockopt(conn->sd, IPPROTO_TCP, TCP_NODELAY, &val,
929 sizeof(val));
930
918 /* get reply */
919 switch (_http_get_reply(conn)) {
920 case HTTP_OK:
921 case HTTP_PARTIAL:
922 /* fine */
923 break;
924 case HTTP_MOVED_PERM:
925 case HTTP_MOVED_TEMP:

--- 275 unchanged lines hidden ---
931 /* get reply */
932 switch (_http_get_reply(conn)) {
933 case HTTP_OK:
934 case HTTP_PARTIAL:
935 /* fine */
936 break;
937 case HTTP_MOVED_PERM:
938 case HTTP_MOVED_TEMP:

--- 275 unchanged lines hidden ---