common/src/main/java/HTTPClient/Util.java
/**
     * Parse the value part. Accepts either token or quoted string.
     */
Parse the value part. Accepts either token or quoted string.
Parse the value part . Accepts either token or quoted string .
private static String parseValue(char[] buf, int[] abeg, String header,
				     boolean dequote)
		throws ParseException
    {
	int beg = abeg[0], end = beg, len = buf.length;
	String value;
	beg = skipSpace(buf, beg);
	if (beg < len  &&  buf[beg] == '"')	
	{
	    beg++;
	    end = beg;
	    char[] deq_buf = null;
	    int    deq_pos = 0, lst_pos = beg;
	    while (end < len  &&  buf[end] != '"')
	    {
		if (buf[end] == '\\')
		{
		    if (dequote)	
		    {
			if (deq_buf == null)
			    deq_buf = new char[buf.length];
			System.arraycopy(buf, lst_pos, deq_buf, deq_pos,
					 end-lst_pos);
			deq_pos += end-lst_pos;
			lst_pos = ++end;
		    }
		    else
			end++;		
		}
		end++;
	    }
	    if (end == len)
		throw new ParseException("Bad header format: '" + header +
					 "'\nClosing <\"> for quoted-string"+
					 " starting at position " +
					 (beg-1) + " not found");
	    if (deq_buf != null)
	    {
		System.arraycopy(buf, lst_pos, deq_buf, deq_pos, end-lst_pos);
		deq_pos += end-lst_pos;
		value = new String(deq_buf, 0, deq_pos);
	    }
	    else
		value = new String(buf, beg, end-beg);
	    end++;
	}
	else					
	{
	    end = beg;
	    while (end < len  &&  !Character.isWhitespace(buf[end])  &&
		   buf[end] != ','  &&  buf[end] != ';')
		end++;
	    value = new String(buf, beg, end-beg);
	}
	abeg[0] = end;
	return value;
    }
private static String parseValue ( char [ ] buf , int [ ] abeg , String header , boolean dequote ) throws ParseException { int beg = abeg [ 0 ] , end = beg , len = buf . length ; String value ; beg = skipSpace ( buf , beg ) ; if ( beg < len && buf [ beg ] == '"' ) { beg ++ ; end = beg ; char [ ] deq_buf = null ; int deq_pos = 0 , lst_pos = beg ; while ( end < len && buf [ end ] != '"' ) { if ( buf [ end ] == '\\' ) { if ( dequote ) { if ( deq_buf == null ) deq_buf = new char [ buf . length ] ; System . arraycopy ( buf , lst_pos , deq_buf , deq_pos , end - lst_pos ) ; deq_pos += end - lst_pos ; lst_pos = ++ end ; } else end ++ ; } end ++ ; } if ( end == len ) throw new ParseException ( "Bad header format: '" + header + "'\nClosing <\"> for quoted-string" + " starting at position " + ( beg - 1 ) + " not found" ) ; if ( deq_buf != null ) { System . arraycopy ( buf , lst_pos , deq_buf , deq_pos , end - lst_pos ) ; deq_pos += end - lst_pos ; value = new String ( deq_buf , 0 , deq_pos ) ; } else value = new String ( buf , beg , end - beg ) ; end ++ ; } else { end = beg ; while ( end < len && ! Character . isWhitespace ( buf [ end ] ) && buf [ end ] != ',' && buf [ end ] != ';' ) end ++ ; value = new String ( buf , beg , end - beg ) ; } abeg [ 0 ] = end ; return value ; }
Parse the value part.
Parse the value part .
// it's a quoted-string // dequote char // skip quoted char // it's a simple token value