sws: support extracting test number from CONNECT ipv6-address!

If an ipv6-address is provided to CONNECT, the last hexadecimal group in
the address will be used as the test number! For example the address
"[1234::ff]" would be treated as test case 255.
This commit is contained in:
Daniel Stenberg 2013-06-04 22:50:58 +02:00
parent 0bf5ce77aa
commit a7452b8b8c
2 changed files with 19 additions and 3 deletions

View File

@ -257,7 +257,9 @@ data that is defined within the <reply><data></data></reply> section.
If there's no test number found above, the HTTP test server will use the If there's no test number found above, the HTTP test server will use the
number following the last dot in the given hostname (made so that a CONNECT number following the last dot in the given hostname (made so that a CONNECT
can still pass on test number) so that "foo.bar.123" gets treated as test case can still pass on test number) so that "foo.bar.123" gets treated as test case
123. 123. Alternatively, if an ipv6-address is provided to CONNECT, the last
hexadecimal group in the address will be used as the test numer! For example
the address "[1234::ff]" would be treated as test case 255.
Set type="perl" to write the test case as a perl script. It implies that Set type="perl" to write the test case as a perl script. It implies that
there's no memory debugging and valgrind gets shut off for this test. there's no memory debugging and valgrind gets shut off for this test.

View File

@ -518,6 +518,7 @@ static int ProcessRequest(struct httprequest *req)
if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
doc, &prot_major, &prot_minor) == 3) { doc, &prot_major, &prot_minor) == 3) {
char *portp = NULL; char *portp = NULL;
unsigned long part=0;
sprintf(logbuf, "Received a CONNECT %s HTTP/%d.%d request", sprintf(logbuf, "Received a CONNECT %s HTTP/%d.%d request",
doc, prot_major, prot_minor); doc, prot_major, prot_minor);
@ -530,14 +531,24 @@ static int ProcessRequest(struct httprequest *req)
if(doc[0] == '[') { if(doc[0] == '[') {
char *p = &doc[1]; char *p = &doc[1];
while(*p && (ISXDIGIT(*p) || (*p == ':') || (*p == '.'))) /* scan through the hexgroups and store the value of the last group
p++; in the 'part' variable and use as test case number!! */
while(*p && (ISXDIGIT(*p) || (*p == ':') || (*p == '.'))) {
char *endp;
part = strtoul(p, &endp, 16);
if(ISXDIGIT(*p))
p = endp;
else
p++;
}
if(*p != ']') if(*p != ']')
logmsg("Invalid CONNECT IPv6 address format"); logmsg("Invalid CONNECT IPv6 address format");
else if (*(p+1) != ':') else if (*(p+1) != ':')
logmsg("Invalid CONNECT IPv6 port format"); logmsg("Invalid CONNECT IPv6 port format");
else else
portp = p+1; portp = p+1;
req->testno = part;
} }
else else
portp = strchr(doc, ':'); portp = strchr(doc, ':');
@ -548,7 +559,10 @@ static int ProcessRequest(struct httprequest *req)
logmsg("Invalid CONNECT port received"); logmsg("Invalid CONNECT port received");
else else
req->connect_port = curlx_ultous(ulnum); req->connect_port = curlx_ultous(ulnum);
} }
logmsg("Port number: %d, test case number: %ld",
req->connect_port, req->testno);
} }
} }