Index: /pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c	(revision 79)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c	(revision 80)
@@ -998,4 +998,5 @@
                                      ... )
 {
+#if PJ_LOG_MAX_LEVEL > 0
     char newformat[256];
     int len;
@@ -1027,4 +1028,10 @@
 
     va_end(marker);
+#else
+    PJ_UNUSED_ARG(format);
+    PJ_UNUSED_ARG(error_code);
+    PJ_UNUSED_ARG(sender);
+    PJ_UNUSED_ARG(endpt);
+#endif
 }
 
@@ -1111,4 +1118,6 @@
     pj_mutex_unlock(endpt->mutex);
 #else
+    PJ_UNUSED_ARG(endpt);
+    PJ_UNUSED_ARG(detail);
     PJ_LOG(3,(THIS_FILE, "pjsip_end_dump: can't dump because it's disabled."));
 #endif
Index: /pjproject/trunk/pjsip/src/pjsip/sip_parser.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_parser.c	(revision 79)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_parser.c	(revision 80)
@@ -53,4 +53,8 @@
 
 #define UNREACHED(expr)
+
+//#define IS_NEWLINE(c)	((c)=='\r' || (c)=='\n')
+#define IS_NEWLINE(c)	((c)=='\r')
+#define IS_SPACE(c)	((c)==' ' || (c)=='\t')
 
 typedef struct handler_rec
@@ -543,5 +547,4 @@
     pj_scanner scanner;
     pjsip_parse_ctx context;
-    PJ_USE_EXCEPTION;
 
     init_sip_parser();
@@ -554,11 +557,5 @@
     context.rdata = NULL;
 
-    PJ_TRY {
-	msg = int_parse_msg(&context, err_list);
-    } 
-    PJ_CATCH_ANY {
-	msg = NULL;
-    }
-    PJ_END
+    msg = int_parse_msg(&context, err_list);
 
     pj_scan_fini(&scanner);
@@ -572,5 +569,4 @@
     pj_scanner scanner;
     pjsip_parse_ctx context;
-    PJ_USE_EXCEPTION;
 
     init_sip_parser();
@@ -583,11 +579,5 @@
     context.rdata = rdata;
 
-    PJ_TRY {
-	rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err);
-    } 
-    PJ_CATCH_ANY {
-	rdata->msg_info.msg = NULL;
-    }
-    PJ_END
+    rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err);
 
     pj_scan_fini(&scanner);
@@ -719,7 +709,5 @@
 
     /* Must have exhausted all inputs. */
-    if (pj_scan_is_eof(&scanner) || *scanner.curptr=='\r' || 
-                       *scanner.curptr=='\n') 
-    {
+    if (pj_scan_is_eof(&scanner) || IS_NEWLINE(*scanner.curptr)) {
 	/* Success. */
 	pj_scan_fini(&scanner);
@@ -751,5 +739,6 @@
 				 pjsip_parser_err_report *err_list)
 {
-    pjsip_msg *msg;
+    pj_bool_t parsing_headers;
+    pjsip_msg *msg = NULL;
     pj_str_t hname;
     pjsip_ctype_hdr *ctype_hdr = NULL;
@@ -758,23 +747,29 @@
     PJ_USE_EXCEPTION;
 
-    /* Skip leading newlines. */
-    while (*scanner->curptr=='\r' || *scanner->curptr=='\n') {
-	pj_scan_get_newline(scanner);
-    }
-
-    /* Parse request or status line */
-    if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) {
-	msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG);
-	int_parse_status_line( scanner, &msg->line.status );
-    } else {
-	msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);
-	int_parse_req_line(scanner, pool, &msg->line.req );
-    }
-
-    /* Parse headers. */
-parse_headers:
+    parsing_headers = PJ_FALSE;
 
     PJ_TRY 
     {
+	if (parsing_headers)
+	    goto parse_headers;
+
+	/* Skip leading newlines. */
+	while (IS_NEWLINE(*scanner->curptr)) {
+	    pj_scan_get_newline(scanner);
+	}
+
+	/* Parse request or status line */
+	if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) {
+	    msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG);
+	    int_parse_status_line( scanner, &msg->line.status );
+	} else {
+	    msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);
+	    int_parse_req_line(scanner, pool, &msg->line.req );
+	}
+
+	parsing_headers = PJ_TRUE;
+
+parse_headers:
+	/* Parse headers. */
 	do {
 	    pjsip_parse_hdr_func * handler;
@@ -796,18 +791,19 @@
 	    if (handler) {
 		hdr = (*handler)(ctx);
+
+		/* Check if we've just parsed a Content-Type header. 
+		 * We will check for a message body if we've got Content-Type 
+		 * header.
+		 */
+		if (hdr->type == PJSIP_H_CONTENT_TYPE) {
+		    ctype_hdr = (pjsip_ctype_hdr*)hdr;
+		}
+
 	    } else {
 		hdr = parse_hdr_generic_string(ctx);
-		hdr->type = PJSIP_H_OTHER;
 		hdr->name = hdr->sname = hname;
 	    }
 	    
-	    /* Check if we've just parsed a Content-Type header. 
-	     * We will check for a message body if we've got Content-Type 
-	     * header.
-	     */
-	    if (hdr->type == PJSIP_H_CONTENT_TYPE) {
-		ctype_hdr = (pjsip_ctype_hdr*)hdr;
-	    }
-		
+	
 	    /* Single parse of header line can produce multiple headers.
 	     * For example, if one Contact: header contains Contact list
@@ -819,7 +815,30 @@
 	    
 	    /* Parse until EOF or an empty line is found. */
-	} while (!pj_scan_is_eof(scanner) && 
-		  *scanner->curptr != '\r' && *scanner->curptr != '\n');
+	} while (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr));
 	
+	parsing_headers = PJ_FALSE;
+
+	/* If empty line is found, eat it. */
+	if (!pj_scan_is_eof(scanner)) {
+	    if (IS_NEWLINE(*scanner->curptr)) {
+		pj_scan_get_newline(scanner);
+	    }
+	}
+
+	/* If we have Content-Type header, treat the rest of the message 
+	 * as body.
+	 */
+	if (ctype_hdr && scanner->curptr!=scanner->end) {
+	    pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body));
+	    body->content_type.type = ctype_hdr->media.type;
+	    body->content_type.subtype = ctype_hdr->media.subtype;
+	    body->content_type.param = ctype_hdr->media.param;
+
+	    body->data = scanner->curptr;
+	    body->len = scanner->end - scanner->curptr;
+	    body->print_body = &generic_print_body;
+
+	    msg->body = body;
+	}
     }
     PJ_CATCH_ANY 
@@ -828,6 +847,4 @@
 	 * Skip until newline, and parse next header. 
 	 */
-	pj_str_t token;
-	
 	if (err_list) {
 	    pjsip_parser_err_report *err_info;
@@ -837,43 +854,30 @@
 	    err_info->line = scanner->line;
 	    err_info->col = pj_scan_get_col(scanner);
-	    err_info->hname = hname;
+	    if (parsing_headers)
+		err_info->hname = hname;
+	    else
+		err_info->hname.slen = 0;
 	    
 	    pj_list_insert_before(err_list, err_info);
 	}
 	
-	if (!pj_scan_is_eof(scanner)) {
-	    pj_scan_get(scanner, &pjsip_NOT_NEWLINE, &token);
-	    parse_hdr_end(scanner);
-	}
-
-	if (!pj_scan_is_eof(scanner) && 
-	    *scanner->curptr != '\r' && *scanner->curptr != '\n');
-	{
-	    goto parse_headers;
-	}
+	if (parsing_headers) {
+	    if (!pj_scan_is_eof(scanner)) {
+		/* Skip until next line.
+		 * Watch for header continuation.
+		 */
+		do {
+		    pj_scan_skip_line(scanner);
+		} while (IS_SPACE(*scanner->curptr));
+	    }
+
+	    if (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)) {
+		goto parse_headers;
+	    }
+	}
+
+	msg = NULL;
     }
     PJ_END;
-
-
-    /* If empty line is found, eat it. */
-    if (!pj_scan_is_eof(scanner)) {
-	if (*scanner->curptr=='\r' || *scanner->curptr=='\n') {
-	    pj_scan_get_newline(scanner);
-	}
-    }
-
-    /* If we have Content-Type header, treat the rest of the message as body.*/
-    if (ctype_hdr && scanner->curptr!=scanner->end) {
-	pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body));
-	body->content_type.type = ctype_hdr->media.type;
-	body->content_type.subtype = ctype_hdr->media.subtype;
-	body->content_type.param = ctype_hdr->media.param;
-
-	body->data = scanner->curptr;
-	body->len = scanner->end - scanner->curptr;
-	body->print_body = &generic_print_body;
-
-	msg->body = body;
-    }
 
     return msg;
Index: /pjproject/trunk/pjsip/src/pjsip/sip_transport.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_transport.c	(revision 79)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_transport.c	(revision 80)
@@ -839,4 +839,6 @@
 
     pj_lock_release(mgr->lock);
+#else
+    PJ_UNUSED_ARG(mgr);
 #endif
 }
