You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@locus.apache.org on 2000/12/07 19:12:49 UTC
cvs commit: httpd-2.0/support ab.c httpd.exp
trawick 00/12/07 10:12:48
Modified: support ab.c httpd.exp
Log:
ab: use apr_parse_addr_port() in parse_url().
httpd.exp: Add the new APR symbol apr_parse_addr_port.
Revision Changes Path
1.43 +23 -44 httpd-2.0/support/ab.c
Index: ab.c
===================================================================
RCS file: /home/cvs/httpd-2.0/support/ab.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- ab.c 2000/12/05 21:02:20 1.42
+++ ab.c 2000/12/07 18:12:48 1.43
@@ -189,9 +189,8 @@
int tlimit = 0; /* time limit in cs */
int keepalive = 0; /* try and do keepalive connections */
char servername[1024]; /* name that server reports */
-char hostname[1024]; /* host name */
+char *hostname; /* host name from URL */
char *host_field; /* value of "Host:" header field */
-int family = APR_UNSPEC; /* requested address family */
char path[1024]; /* path name */
char postfile[1024]; /* name of file containing post data */
char *postdata; /* *buffer containing data from postfile */
@@ -201,7 +200,7 @@
auth[1024], /* optional (basic/uuencoded)
* authentification */
hdrs[4096]; /* optional arbitrary headers */
-int port = 80; /* port number */
+apr_port_t port; /* port number */
apr_time_t aprtimeout = 30 * APR_USEC_PER_SEC; /* timeout value */
int use_html = 0; /* use html in the report */
@@ -300,7 +299,7 @@
printf("\r \r");
printf("Server Software: %s\n", servername);
printf("Server Hostname: %s\n", hostname);
- printf("Server Port: %d\n", port);
+ printf("Server Port: %hd\n", port);
printf("\n");
printf("Document Path: %s\n", path);
printf("Document Length: %d bytes\n", doclen);
@@ -382,7 +381,7 @@
"<td colspan=2 %s>%s</td></tr>\n",
trstring, tdstring, tdstring, hostname);
printf("<tr %s><th colspan=2 %s>Server Port:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
+ "<td colspan=2 %s>%hd</td></tr>\n",
trstring, tdstring, tdstring, port);
printf("<tr %s><th colspan=2 %s>Document Path:</th>"
"<td colspan=2 %s>%s</td></tr>\n",
@@ -504,7 +503,7 @@
c->cbx = 0;
c->gotheader = 0;
- if ((rv = apr_getaddrinfo(&destsa, hostname, family, port, 0, cntxt))
+ if ((rv = apr_getaddrinfo(&destsa, hostname, APR_UNSPEC, port, 0, cntxt))
!= APR_SUCCESS) {
char buf[120];
@@ -514,7 +513,7 @@
}
if ((rv = apr_create_socket(&c->aprsock, destsa->sa.sin.sin_family,
SOCK_STREAM, cntxt)) != APR_SUCCESS) {
- apr_err("Socket:", rv);
+ apr_err("socket", rv);
}
c->start = apr_now();
if ((rv = apr_connect(c->aprsock, destsa)) != APR_SUCCESS) {
@@ -895,14 +894,14 @@
static void copyright(void)
{
if (!use_html) {
- printf("This is ApacheBench, Version %s\n", AB_VERSION " <$Revision: 1.42 $> apache-2.0");
+ printf("This is ApacheBench, Version %s\n", AB_VERSION " <$Revision: 1.43 $> apache-2.0");
printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
printf("Copyright (c) 1998-2000 The Apache Software Foundation, http://www.apache.org/\n");
printf("\n");
}
else {
printf("<p>\n");
- printf(" This is ApacheBench, Version %s <i><%s></i> apache-2.0<br>\n", AB_VERSION, "$Revision: 1.42 $");
+ printf(" This is ApacheBench, Version %s <i><%s></i> apache-2.0<br>\n", AB_VERSION, "$Revision: 1.43 $");
printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
printf(" Copyright (c) 1998-2000 The Apache Software Foundation, http://www.apache.org/<br>\n");
printf("</p>\n<p>\n");
@@ -946,51 +945,31 @@
{
char *cp;
char *h;
- char *p = NULL; /* points to port if url has it */
+ char *scope_id;
+ apr_status_t rv;
if (strlen(url) > 7 && strncmp(url, "http://", 7) == 0)
url += 7;
- h = url;
-#if APR_HAVE_INET6
- if (*url == '[') { /* RFC 2732 format */
- h = url + 1;
- url = strchr(h, ']');
- if (!url) { /* malformed IPv6 literal address format */
- return 1;
- }
- *url = '\0';
- ++url;
- /* According to RFC 2732, this syntax is allowed only for IPv6 numeric
- * address strings, so set the family passed to apr_getaddrinfo() so
- * that it fails if the hostname is IPv4.
- *
- * It is certainly possible that the hostname parameter isn't a numeric
- * address string; that error won't be caught here.
- */
- family = APR_INET6;
- }
-#endif /* APR_HAVE_INET6 */
- if ((cp = strchr(url, ':')) != NULL) {
- *cp++ = '\0';
- p = cp;
- url = cp;
- }
if ((cp = strchr(url, '/')) == NULL)
return 1;
+ h = apr_palloc(cntxt, cp - url + 1);
+ memcpy(h, url, cp - url);
+ h[cp - url] = '\0';
+ rv = apr_parse_addr_port(&hostname, &scope_id, &port, h, cntxt);
+ if (rv != APR_SUCCESS || !hostname || scope_id) {
+ return 1;
+ }
strcpy(path, cp);
*cp = '\0';
- strcpy(hostname, h);
-#if APR_HAVE_INET6
- if (family == APR_INET6) {
- host_field = apr_psprintf(cntxt, "[%s]",hostname);
+ if (*url == '[') { /* IPv6 numeric address string */
+ host_field = apr_psprintf(cntxt, "[%s]", hostname);
}
- else
-#endif /* APR_HAVE_INET6 */
- {
+ else {
host_field = hostname;
+ }
+ if (port == 0) { /* no port specified */
+ port = 80;
}
- if (p != NULL)
- port = atoi(p);
return 0;
}
1.19 +1 -0 httpd-2.0/support/httpd.exp
Index: httpd.exp
===================================================================
RCS file: /home/cvs/httpd-2.0/support/httpd.exp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- httpd.exp 2000/12/06 06:01:01 1.18
+++ httpd.exp 2000/12/07 18:12:48 1.19
@@ -467,6 +467,7 @@
apr_overlap_tables
apr_overlay_tables
apr_palloc
+apr_parse_addr_port
apr_parse_uuid
apr_pcalloc
apr_poll