/*
- * "$Id: testhttp.c 4809 2005-10-21 19:43:55Z mike $"
+ * "$Id: testhttp.c 6649 2007-07-11 21:46:42Z mike $"
*
* HTTP test program for the Common UNIX Printing System (CUPS).
*
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* This file is subject to the Apple OS-Developed Software exception.
*
"http", "username:password", "server", "/", 8080, 8080 },
{ HTTP_URI_OK, "http://username:passwor%64@server:8080/directory/filename",
"http", "username:password", "server", "/directory/filename", 8080, 8080 },
+ { HTTP_URI_OK, "http://[2000::10:100]:631/ipp",
+ "http", "", "2000::10:100", "/ipp", 631, 631 },
{ HTTP_URI_OK, "https://username:passwor%64@server/directory/filename",
"https", "username:password", "server", "/directory/filename", 443, 0 },
{ HTTP_URI_OK, "ipp://username:passwor%64@[::1]/ipp",
"mailto", "", "", "user@domain.com", 0, 0 },
{ HTTP_URI_OK, "socket://server/",
"socket", "", "server", "/", 9100, 0 },
+ { HTTP_URI_OK, "socket://192.168.1.1:9101/",
+ "socket", "", "192.168.1.1", "/", 9101, 9101 },
{ HTTP_URI_OK, "ipp://username:password@[v1.fe80::200:1234:5678:9abc+eth0]:999/ipp",
"ipp", "username:password", "fe80::200:1234:5678:9abc%eth0", "/ipp", 999, 999 },
+ { HTTP_URI_OK, "http://server/admin?DEVICE_URI=usb://HP/Photosmart%25202600%2520series?serial=MY53OK70V10400",
+ "http", "", "server", "/admin?DEVICE_URI=usb://HP/Photosmart%25202600%2520series?serial=MY53OK70V10400", 80, 0 },
/* Missing scheme */
{ HTTP_URI_MISSING_SCHEME, "/path/to/file/index.html",
/* Missing resource */
{ HTTP_URI_MISSING_RESOURCE, "socket://[::192.168.2.1]",
"socket", "", "::192.168.2.1", "/", 9100, 0 },
+ { HTTP_URI_MISSING_RESOURCE, "socket://192.168.1.1:9101",
+ "socket", "", "192.168.1.1", "/", 9101 },
/* Bad URI */
{ HTTP_URI_BAD_URI, "",
fputs("httpGetHostname(): ", stdout);
- if (httpGetHostname(hostname, sizeof(hostname)))
+ if (httpGetHostname(NULL, hostname, sizeof(hostname)))
printf("PASS (%s)\n", hostname);
else
{
addrlist = httpAddrGetList(hostname, AF_UNSPEC, NULL);
if (addrlist)
{
- for (i = 0, addr = addrlist; addr; i ++, addr = addr->next);
+ for (i = 0, addr = addrlist; addr; i ++, addr = addr->next)
+ {
+ char numeric[1024]; /* Numeric IP address */
+
+
+ httpAddrString(&(addr->addr), numeric, sizeof(numeric));
+ if (!strcmp(numeric, "UNKNOWN"))
+ break;
+ }
+
+ if (addr)
+ printf("FAIL (bad address for %s)\n", hostname);
+ else
+ printf("PASS (%d address(es) for %s)\n", i, hostname);
- printf("PASS (%d address(es) for %s)\n", i, hostname);
httpAddrFreeList(addrlist);
}
else
fputs("httpSeparateURI(): ", stdout);
for (i = 0, j = 0; i < (int)(sizeof(uri_tests) / sizeof(uri_tests[0])); i ++)
{
- uri_status = httpSeparateURI(uri_tests[i].uri, scheme, sizeof(scheme),
+ uri_status = httpSeparateURI(HTTP_URI_CODING_MOST,
+ uri_tests[i].uri, scheme, sizeof(scheme),
username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
strstr(uri_tests[i].uri, "//"))
{
k ++;
- uri_status = httpAssembleURI(buffer, sizeof(buffer),
+ uri_status = httpAssembleURI(HTTP_URI_CODING_MOST,
+ buffer, sizeof(buffer),
uri_tests[i].scheme,
uri_tests[i].username,
uri_tests[i].hostname,
continue;
}
- httpSeparateURI(argv[i], scheme, sizeof(scheme), username, sizeof(username),
+ httpSeparateURI(HTTP_URI_CODING_MOST, argv[i], scheme, sizeof(scheme),
+ username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
length = httpGetLength2(http);
total = 0;
- while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
+ while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
{
total += bytes;
fwrite(buffer, bytes, 1, out);
current = time(NULL);
if (current == start) current ++;
printf("\r" CUPS_LLFMT "/" CUPS_LLFMT " bytes ("
- CUPS_LLFMT " bytes/sec) ", total, length,
- total / (current - start));
+ CUPS_LLFMT " bytes/sec) ", CUPS_LLCAST total,
+ CUPS_LLCAST length, CUPS_LLCAST (total / (current - start)));
fflush(stdout);
}
}
/*
- * End of "$Id: testhttp.c 4809 2005-10-21 19:43:55Z mike $".
+ * End of "$Id: testhttp.c 6649 2007-07-11 21:46:42Z mike $".
*/