src/org/jnetpcap/packet/AbstractMessageHeader.java
@Override
	protected void decodeHeader() {

		super.clearFields();

		/*
		 * Note: this parser is not really robust enough to parse entire syntax, but
		 * has done OK job so far. We should plan on replacing it with at a more
		 * robust tokenizer/parser that can handle all corner cases more efficiently
		 * and reliably.
		 */

		/*
		 * We already know the length of the header, so just get the raw chars
		 */
		final StringBuilder buf = stringLocal.get();
		buf.setLength(0);
		int len = super.getLength();
		super.getUTF8String(0, buf, len);

		rawHeader = buf.toString();
		String lines[] = rawHeader.split("\r\n|\n");

		// System.out.println("[" + s + "]");

		buf.setLength(0);
		for (int i = 0; i < lines.length; i++) {
			String line = lines[i];
			if (line.length() == 0) {
				continue; // Skip 0 length/blank lines
			}

			/*
			 * First check if lines need to be combined if first character is a space
			 * or a tab. This indicates line continuation and all leading white space
			 * is replaced with a single space.
			 */
			char firstChar = line.charAt(0);
			if (firstChar == ' ' || firstChar == '\t') {
				line = line.trim();
				if (buf.length() != 0) {
					buf.append(' ');
				}

				buf.append(line);
				continue;
			} else {

				/*
				 * Check if we have any buffered string in the buffer from the
				 * recombining process. If yes, we make take the string out of the
				 * buffer and process it, while we decrement i pointer, to rerun the
				 * lines[i] which was just used as an indicator that no more lines are
				 * to be recombined.
				 */
				if (buf.length() != 0) {
					line = buf.toString();
					buf.setLength(0);
					i--;
				}
			}

			String c[] = line.split(":", 2);

			if (c.length == 1) {
				if (c[0].length() > 0) {
					decodeFirstLine(c[0]);
				}
				continue;
			}

			if (c.length < 2) {
				continue; // We need at least 2 sections or something is wrong
			}

			// System.out.printf("[%s]=[%s]\n", c[0], c[1]);
			String name = c[0];
			String value = c[1];
			int offset = rawHeader.indexOf(name + ":");
			int length = name.length() + value.length() + 1;

			super.addField(map(name.trim()), value.trim(), offset, length);
		}
	}
/**
	 * Decode the http/sip header. First we need to convert raw bytes to a char's
	 * we can deal with since Http/sip header is text based. Once converted we can
	 * then accurately determine the Http/sip header length, type of request,
	 * etc...
	 */
Decode the http/sip header. First we need to convert raw bytes to a char's
we can deal with since Http/sip header is text based. Once converted we can
then accurately determine the Http/sip header length, type of request,
etc
Decode the http / sip header . First we need to convert raw bytes to a char ' s we can deal with since Http / sip header is text based . Once converted we can then accurately determine the Http / sip header length type of request etc
@Override
	protected void decodeHeader() {
		super.clearFields();
		/*
		 * Note: this parser is not really robust enough to parse entire syntax, but
		 * has done OK job so far. We should plan on replacing it with at a more
		 * robust tokenizer/parser that can handle all corner cases more efficiently
		 * and reliably.
		 */
		/*
		 * We already know the length of the header, so just get the raw chars
		 */
		final StringBuilder buf = stringLocal.get();
		buf.setLength(0);
		int len = super.getLength();
		super.getUTF8String(0, buf, len);
		rawHeader = buf.toString();
		String lines[] = rawHeader.split("\r\n|\n");
		buf.setLength(0);
		for (int i = 0; i < lines.length; i++) {
			String line = lines[i];
			if (line.length() == 0) {
				continue; 
			}
			/*
			 * First check if lines need to be combined if first character is a space
			 * or a tab. This indicates line continuation and all leading white space
			 * is replaced with a single space.
			 */
			char firstChar = line.charAt(0);
			if (firstChar == ' ' || firstChar == '\t') {
				line = line.trim();
				if (buf.length() != 0) {
					buf.append(' ');
				}
				buf.append(line);
				continue;
			} else {
				/*
				 * Check if we have any buffered string in the buffer from the
				 * recombining process. If yes, we make take the string out of the
				 * buffer and process it, while we decrement i pointer, to rerun the
				 * lines[i] which was just used as an indicator that no more lines are
				 * to be recombined.
				 */
				if (buf.length() != 0) {
					line = buf.toString();
					buf.setLength(0);
					i--;
				}
			}
			String c[] = line.split(":", 2);
			if (c.length == 1) {
				if (c[0].length() > 0) {
					decodeFirstLine(c[0]);
				}
				continue;
			}
			if (c.length < 2) {
				continue; 
			}
			String name = c[0];
			String value = c[1];
			int offset = rawHeader.indexOf(name + ":");
			int length = name.length() + value.length() + 1;
			super.addField(map(name.trim()), value.trim(), offset, length);
		}
	}
@ Override protected void decodeHeader ( ) { super . clearFields ( ) ; /*
		 * Note: this parser is not really robust enough to parse entire syntax, but
		 * has done OK job so far. We should plan on replacing it with at a more
		 * robust tokenizer/parser that can handle all corner cases more efficiently
		 * and reliably.
		 */ /*
		 * We already know the length of the header, so just get the raw chars
		 */ final StringBuilder buf = stringLocal . get ( ) ; buf . setLength ( 0 ) ; int len = super . getLength ( ) ; super . getUTF8String ( 0 , buf , len ) ; rawHeader = buf . toString ( ) ; String lines [ ] = rawHeader . split ( "\r\n|\n" ) ; buf . setLength ( 0 ) ; for ( int i = 0 ; i < lines . length ; i ++ ) { String line = lines [ i ] ; if ( line . length ( ) == 0 ) { continue ; } /*
			 * First check if lines need to be combined if first character is a space
			 * or a tab. This indicates line continuation and all leading white space
			 * is replaced with a single space.
			 */ char firstChar = line . charAt ( 0 ) ; if ( firstChar == ' ' || firstChar == '\t' ) { line = line . trim ( ) ; if ( buf . length ( ) != 0 ) { buf . append ( ' ' ) ; } buf . append ( line ) ; continue ; } else { /*
				 * Check if we have any buffered string in the buffer from the
				 * recombining process. If yes, we make take the string out of the
				 * buffer and process it, while we decrement i pointer, to rerun the
				 * lines[i] which was just used as an indicator that no more lines are
				 * to be recombined.
				 */ if ( buf . length ( ) != 0 ) { line = buf . toString ( ) ; buf . setLength ( 0 ) ; i -- ; } } String c [ ] = line . split ( ":" , 2 ) ; if ( c . length == 1 ) { if ( c [ 0 ] . length ( ) > 0 ) { decodeFirstLine ( c [ 0 ] ) ; } continue ; } if ( c . length < 2 ) { continue ; } String name = c [ 0 ] ; String value = c [ 1 ] ; int offset = rawHeader . indexOf ( name + ":" ) ; int length = name . length ( ) + value . length ( ) + 1 ; super . addField ( map ( name . trim ( ) ) , value . trim ( ) , offset , length ) ; } }
Decode the http/sip header.
Decode the http / sip header .
// System.out.println("[" + s + "]"); // Skip 0 length/blank lines // We need at least 2 sections or something is wrong // System.out.printf("[%s]=[%s]\n", c[0], c[1]);