Bug #850674 fixed with the new -R option to accept HTTP redirects

MAINT_6_0
Stephane Bortzmeyer 17 years ago
parent dd04b58c2f
commit 4ae4d0bee0

@ -18,7 +18,8 @@ echoping \- tests a remote host with TCP or UDP
.RI [-s size]
.RI [-n number]
.RI [-w delay]
.RI [-h url]
.RI [-h url]
.RI [-R]
.RI [-i url]
.RI [-p priority]
.RI [-P tos]
@ -91,6 +92,9 @@ be a relative one (for instance '/' or '/pics/foobar.gif') because HTTP 1.0
servers will not understand a request for an absolute URL. If the
hostname is a proxy/cache like Squid, the URL has to
be an absolute one.
.IP -R
Accept HTTP status codes 3xx (redirections) as normal responses (the
default is to regard them as errors)
.IP -i\ url
Use the ICP protocol (instead of echo) for the given URL. The URL has to
be an absolute one. This is mostly for testing Squid Web proxy/caches.

@ -69,6 +69,7 @@ main (argc, argv)
char rand_file[MAX_LINE];
#endif
char *sendline, recvline[MAX_LINE + 1];
boolean accept_http_redirects = FALSE;
#ifdef ICP
char retcode[DEFLINE];
int length;
@ -159,6 +160,8 @@ main (argc, argv)
{"discard", 'd', POPT_ARG_NONE, &discard, 'd'},
{"chargen", 'c', POPT_ARG_NONE, &chargen, 'c'},
{"http", 'h', POPT_ARG_STRING, &url, 'h'},
{"accept-http-redirects", 'R', POPT_ARG_NONE, &accept_http_redirects, 'R',
"Accept HTTP return codes 3xx (redirections)"},
{"icp", 'i', POPT_ARG_STRING, &url, 'i',
"ICP protocol, for Web proxies/caches"},
{"ttcp", 'r', POPT_ARG_NONE, &ttcp, 'r',
@ -262,6 +265,9 @@ main (argc, argv)
port_to_use = USE_HTTP;
http = 1;
break;
case 'R':
accept_http_redirects = TRUE;
break;
case 'a':
nocache = 1;
break;
@ -434,6 +440,13 @@ main (argc, argv)
{
strcpy (port_name, DEFAULT_HTTPS_TCP_PORT);
}
if (!http && accept_http_redirects)
{
(void) fprintf (stderr,
"%s: accept-http-redirects does not make sens if you do not use HTTP.\n",
progname);
exit (1);
}
#ifndef USE_TOS
if (tos_requested)
{
@ -536,7 +549,10 @@ main (argc, argv)
tcp = 1;
}
if (remaining == 0)
usage (poptcon);
{
(void) fprintf (stderr, "No host name indicated\n");
usage (poptcon);
}
if (!module_find && remaining != 1)
{
printf ("%d args remaining, should be 1\n", remaining);
@ -1242,7 +1258,9 @@ main (argc, argv)
else
channel.tls = session;
#endif
nr = read_from_server (channel, ssl);
nr =
read_from_server (channel, ssl,
accept_http_redirects);
}
#endif
#ifdef SMTP

@ -50,7 +50,7 @@ make_http_sendline (char *url, char *host, int port, int nocache)
}
int
read_from_server (CHANNEL fs, short ssl)
read_from_server (CHANNEL fs, short ssl, boolean accept_redirects)
{
int nr = 0;
int total = 0;
@ -101,8 +101,10 @@ read_from_server (CHANNEL fs, short ssl)
if (first_line)
{
reply_code = big_recvline[9]; /* 9 because "HTTP/1.x 200..." */
if (reply_code != '2') /* Status codes beginning with 3 are not errors
but should never appear in reply to echoping's requests */
if (reply_code != '2' && !(reply_code == '3' && accept_redirects))
/* Status codes beginning with 3 are not errors
See bug #850674 and RFC 2616, section
10.3 */
err_quit ("HTTP error \"%s\"", big_recvline);
}
total = total + nr;

Loading…
Cancel
Save