WebDAV support, and rewrite of the method-testing code to compute the

method length and use that in all comparisons, from Blair Cooper.

Fix the check for "M-" to check also whether there are at least two
characters in the line.

svn path=/trunk/; revision=5071
This commit is contained in:
Guy Harris 2002-04-01 21:12:31 +00:00
parent 3d6dc60340
commit f969aba211
3 changed files with 110 additions and 56 deletions

View File

@ -1123,6 +1123,10 @@ Diana Eichert <deicher[AT]sandia.gov> {
"-q" flag to Tethereal to suppress packet count display "-q" flag to Tethereal to suppress packet count display
} }
Blair Cooper <blair[AT]teamon.com> {
WebDAV support
}
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c. give his permission to use his version of snprintf.c.

View File

@ -1392,6 +1392,7 @@ B<http://www.ethereal.com>.
Jim Sienicki <sienicki[AT]issanni.com> Jim Sienicki <sienicki[AT]issanni.com>
Steven French <sfrench[AT]us.ibm.com> Steven French <sfrench[AT]us.ibm.com>
Diana Eichert <deicher[AT]sandia.gov> Diana Eichert <deicher[AT]sandia.gov>
Blair Cooper <blair[AT]teamon.com>
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to give his Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c. permission to use his version of snprintf.c.

View File

@ -3,7 +3,7 @@
* *
* Guy Harris <guy@alum.mit.edu> * Guy Harris <guy@alum.mit.edu>
* *
* $Id: packet-http.c,v 1.46 2002/01/24 09:20:48 guy Exp $ * $Id: packet-http.c,v 1.47 2002/04/01 21:12:30 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com> * By Gerald Combs <gerald@ethereal.com>
@ -292,13 +292,15 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static int static int
is_http_request_or_reply(const u_char *data, int linelen, http_type_t *type) is_http_request_or_reply(const u_char *data, int linelen, http_type_t *type)
{ {
int isHttpRequestOrReply = FALSE;
/* /*
* From RFC 2774 - An HTTP Extension Framework * From RFC 2774 - An HTTP Extension Framework
* *
* Support the command prefix that identifies the presence of * Support the command prefix that identifies the presence of
* a "mandatory" header. * a "mandatory" header.
*/ */
if (strncmp(data, "M-", 2) == 0) { if (linelen >= 2 && strncmp(data, "M-", 2) == 0) {
data += 2; data += 2;
linelen -= 2; linelen -= 2;
} }
@ -310,72 +312,119 @@ is_http_request_or_reply(const u_char *data, int linelen, http_type_t *type)
* From draft-ietf-dasl-protocol-00.txt, a now vanished Microsoft draft: * From draft-ietf-dasl-protocol-00.txt, a now vanished Microsoft draft:
* SEARCH * SEARCH
*/ */
if (linelen >= 4) { if (linelen >= 5 && strncmp(data, "HTTP/", 5) == 0) {
if (strncmp(data, "GET ", 4) == 0 || *type = HTTP_RESPONSE;
strncmp(data, "PUT ", 4) == 0) { isHttpRequestOrReply = TRUE; /* response */
if (*type == HTTP_OTHERS) } else {
u_char * ptr = (u_char *)data;
int index = 0;
/* Look for the space following the Method */
while (index < linelen) {
if (*ptr == ' ')
break;
else {
ptr++;
index++;
}
}
/* Check the methods that have same length */
switch (index) {
case 3:
if (strncmp(data, "GET", index) == 0 ||
strncmp(data, "PUT", index) == 0) {
*type = HTTP_REQUEST; *type = HTTP_REQUEST;
return TRUE; isHttpRequestOrReply = TRUE;
} }
} break;
if (linelen >= 5) {
if (strncmp(data, "HEAD ", 5) == 0 || case 4:
strncmp(data, "POST ", 5) == 0) { if (strncmp(data, "COPY", index) == 0 ||
if (*type == HTTP_OTHERS) strncmp(data, "HEAD", index) == 0 ||
strncmp(data, "LOCK", index) == 0 ||
strncmp(data, "MOVE", index) == 0 ||
strncmp(data, "POLL", index) == 0 ||
strncmp(data, "POST", index) == 0) {
*type = HTTP_REQUEST; *type = HTTP_REQUEST;
return TRUE; isHttpRequestOrReply = TRUE;
} }
if (strncmp(data, "HTTP/", 5) == 0) { break;
if (*type == HTTP_OTHERS)
*type = HTTP_RESPONSE; case 5:
return TRUE; /* response */ if (strncmp(data, "BCOPY", index) == 0 ||
} strncmp(data, "BMOVE", index) == 0 ||
} strncmp(data, "MKCOL", index) == 0 ||
if (linelen >= 6) { strncmp(data, "TRACE", index) == 0) {
if (strncmp(data, "TRACE ", 6) == 0) {
if (*type == HTTP_OTHERS)
*type = HTTP_REQUEST; *type = HTTP_REQUEST;
return TRUE; isHttpRequestOrReply = TRUE;
} }
} break;
if (linelen >= 7) {
if (strncmp(data, "DELETE ", 7) == 0) { case 6:
if (*type == HTTP_OTHERS) if (strncmp(data, "DELETE", index) == 0 ||
strncmp(data, "SEARCH", index) == 0 ||
strncmp(data, "UNLOCK", index) == 0) {
*type = HTTP_REQUEST; *type = HTTP_REQUEST;
return TRUE; isHttpRequestOrReply = TRUE;
} }
if (strncmp(data, "NOTIFY ", 7) == 0 || else if (strncmp(data, "NOTIFY", index) == 0) {
strncmp(data, "SEARCH ", 7) == 0) {
if (*type == HTTP_OTHERS)
*type = HTTP_NOTIFICATION; *type = HTTP_NOTIFICATION;
return TRUE; isHttpRequestOrReply = TRUE;
} }
} break;
if (linelen >= 8) {
if (strncmp(data, "OPTIONS ", 8) == 0 || case 7:
strncmp(data, "CONNECT ", 8) == 0) { if (strncmp(data, "BDELETE", index) == 0 ||
if (*type == HTTP_OTHERS) strncmp(data, "CONNECT", index) == 0 ||
strncmp(data, "OPTIONS", index) == 0) {
*type = HTTP_REQUEST; *type = HTTP_REQUEST;
return TRUE; isHttpRequestOrReply = TRUE;
} }
} break;
if (linelen >= 10) {
if (strncmp(data, "SUBSCRIBE ", 10) == 0) { case 8:
if (*type == HTTP_OTHERS) if (strncmp(data, "PROPFIND", index) == 0) {
*type = HTTP_REQUEST;
isHttpRequestOrReply = TRUE;
}
break;
case 9:
if (strncmp(data, "SUBSCRIBE", index) == 0) {
*type = HTTP_NOTIFICATION; *type = HTTP_NOTIFICATION;
return TRUE; isHttpRequestOrReply = TRUE;
} } else if (strncmp(data, "PROPPATCH", index) == 0 ||
} strncmp(data, "BPROPFIND", index) == 0) {
if (linelen >= 12) { *type = HTTP_REQUEST;
if (strncmp(data, "UNSUBSCRIBE ", 10) == 0) { isHttpRequestOrReply = TRUE;
if (*type == HTTP_OTHERS) }
break;
case 10:
if (strncmp(data, "BPROPPATCH", index) == 0) {
*type = HTTP_REQUEST;
isHttpRequestOrReply = TRUE;
}
break;
case 11:
if (strncmp(data, "UNSUBSCRIBE", index) == 0) {
*type = HTTP_NOTIFICATION; *type = HTTP_NOTIFICATION;
return TRUE; isHttpRequestOrReply = TRUE;
}
break;
default:
break;
} }
} }
return FALSE;
return isHttpRequestOrReply;
} }
void void
proto_register_http(void) proto_register_http(void)
{ {