2
0
Эх сурвалжийг харах

core: added missing parsed flags & minor get_hdr optimization

- parsed flags were not set for some headers (ACCEPTCONTACT,
ALLOWEVENTS, CONTENTENCODING, REFERREDBY, REJECTCONTACT,
REQUESTDISPOSITION, WWW_AUTHENTICATE, PROXY_AUTHENTICATE,
RETRY_AFTER).

- get_hdr() now checks first if the required header type was
  parsed using the parsed flags. If it was not, it exists
  immediately (it does not try to search through all the headers
  anymore).
Andrei Pelinescu-Onciul 15 жил өмнө
parent
commit
e040485765

+ 6 - 4
parser/msg_parser.c

@@ -364,7 +364,8 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 			case HDR_WWW_AUTHENTICATE_T:
 			case HDR_WWW_AUTHENTICATE_T:
 			case HDR_PROXY_AUTHENTICATE_T:
 			case HDR_PROXY_AUTHENTICATE_T:
 			case HDR_RETRY_AFTER_T:
 			case HDR_RETRY_AFTER_T:
-			case HDR_OTHER_T: /*do nothing*/
+			case HDR_OTHER_T: /* mark the type as found/parsed*/
+				msg->parsed_flag|=HDR_T2F(hf->type);
 				break;
 				break;
 			case HDR_CALLID_T:
 			case HDR_CALLID_T:
 				if (msg->callid==0) msg->callid=hf;
 				if (msg->callid==0) msg->callid=hf;
@@ -830,9 +831,10 @@ struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht)
 {
 {
 	struct hdr_field *hdr;
 	struct hdr_field *hdr;
 
 
-	for(hdr = msg->headers; hdr; hdr = hdr->next) {
-		if(hdr->type == ht) return hdr;
-	}
+	if (msg->parsed_flag & HDR_T2F(ht))
+		for(hdr = msg->headers; hdr; hdr = hdr->next) {
+			if(hdr->type == ht) return hdr;
+		}
 	return NULL;
 	return NULL;
 }
 }