Provide a new `-b' flag to work around some broken HTTP/TCP implementations

that can't deal with a half-closed connection.
This commit is contained in:
Garrett Wollman 1997-07-25 19:35:44 +00:00
parent 21cd47e85e
commit 0c8cc99e5b
4 changed files with 25 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.\" $Id: fetch.1,v 1.16 1997/02/22 23:43:32 wosch Exp $ .\" $Id: fetch.1,v 1.17 1997/03/05 18:57:15 fenner Exp $
.Dd July 2, 1996 .Dd July 2, 1996
.Dt FETCH 1 .Dt FETCH 1
.Os FreeBSD 2.2 .Os FreeBSD 2.2
@ -7,7 +7,7 @@
.Nd retrieve a file by Uniform Resource Locator .Nd retrieve a file by Uniform Resource Locator
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm fetch .Nm fetch
.Op Fl MPamnpqr .Op Fl MPabmnpqr
.Op Fl o Ar file .Op Fl o Ar file
.Ar URL .Ar URL
.Op Ar ... .Op Ar ...
@ -48,6 +48,12 @@ The following options are available:
.Bl -tag -width Fl .Bl -tag -width Fl
.It Fl a .It Fl a
Automatically retry the transfer upon soft failures. Automatically retry the transfer upon soft failures.
.It Fl b
Work around a bug in some
.Tn HTTP
servers which fail to correctly implement the
.Tn TCP
protocol.
.It Fl c Ar dir .It Fl c Ar dir
The file to retrieve is in directory The file to retrieve is in directory
.Ar dir .Ar dir
@ -301,3 +307,7 @@ Only the
authentication mode is implemented for authentication mode is implemented for
.Tn HTTP . .Tn HTTP .
This should be replaced by digest authentication. This should be replaced by digest authentication.
.Pp
The
.Fl b
flag should not be necessary.

View File

@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: fetch.h,v 1.2 1997/01/31 19:55:49 wollman Exp $ * $Id: fetch.h,v 1.3 1997/02/05 19:59:10 wollman Exp $
*/ */
#ifndef fetch_h #ifndef fetch_h
@ -49,6 +49,7 @@ struct fetch_state {
int fs_linkfile; /* -l option */ int fs_linkfile; /* -l option */
int fs_precious; /* -R option */ int fs_precious; /* -R option */
int fs_auto_retry; /* -a option */ int fs_auto_retry; /* -a option */
int fs_linux_bug; /* -b option */
time_t fs_modtime; time_t fs_modtime;
void *fs_proto; void *fs_proto;
int (*fs_retrieve)(struct fetch_state *); int (*fs_retrieve)(struct fetch_state *);

View File

@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: http.c,v 1.5 1997/03/05 18:57:16 fenner Exp $ * $Id: http.c,v 1.6 1997/03/06 20:01:32 jmg Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -483,7 +483,7 @@ http_retrieve(struct fetch_state *fs)
n = 0; n = 0;
msg.msg_control = 0; msg.msg_control = 0;
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = MSG_EOF; msg.msg_flags = fs->fs_linux_bug ? 0 : MSG_EOF;
#define addstr(Iov, N, Str) \ #define addstr(Iov, N, Str) \
do { \ do { \
@ -575,7 +575,7 @@ http_retrieve(struct fetch_state *fs)
fs->fs_status = "sending request message"; fs->fs_status = "sending request message";
setup_sigalrm(); setup_sigalrm();
alarm(timo); alarm(timo);
if (sendmsg(s, &msg, MSG_EOF) < 0) { if (sendmsg(s, &msg, fs->fs_linux_bug ? 0 : MSG_EOF) < 0) {
warn("sendmsg: %s", https->http_hostname); warn("sendmsg: %s", https->http_hostname);
fclose(remote); fclose(remote);
return EX_OSERR; return EX_OSERR;

View File

@ -24,7 +24,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/* $Id: main.c,v 1.39 1997/07/01 06:37:34 charnier Exp $ */ /* $Id: main.c,v 1.40 1997/07/02 06:28:32 charnier Exp $ */
#include <sys/types.h> #include <sys/types.h>
@ -73,7 +73,7 @@ main(int argc, char *const *argv)
fs.fs_verbose = 1; fs.fs_verbose = 1;
change_to_dir = file_to_get = hostname = 0; change_to_dir = file_to_get = hostname = 0;
while ((c = getopt(argc, argv, "ac:D:f:h:HilLmMnNo:pPqRrT:vV:")) != -1) { while ((c = getopt(argc, argv, "abc:D:f:h:HilLmMnNo:pPqRrT:vV:")) != -1) {
switch (c) { switch (c) {
case 'D': case 'H': case 'I': case 'N': case 'L': case 'V': case 'D': case 'H': case 'I': case 'N': case 'L': case 'V':
break; /* ncftp compatibility */ break; /* ncftp compatibility */
@ -81,6 +81,11 @@ main(int argc, char *const *argv)
case 'a': case 'a':
fs.fs_auto_retry = 1; fs.fs_auto_retry = 1;
break; break;
case 'b':
fs.fs_linux_bug = 1;
break;
case 'c': case 'c':
change_to_dir = optarg; change_to_dir = optarg;
break; break;