src/HTTPClient/HTTPConnection.java
/**
     * This merges built-in default headers, user-specified default headers,
     * and method-specified headers. Method-specified take precedence over
     * user defaults, which take precedence over built-in defaults.
     *
     * The following headers are removed if found: "Content-length".
     *
     * @param  spec   the headers specified in the call to the method
     * @return an array consisting of merged headers.
     */
This merges built-in default headers, user-specified default headers,
and method-specified headers. Method-specified take precedence over
user defaults, which take precedence over built-in defaults.

The following headers are removed if found: "Content-length".

@param  spec   the headers specified in the call to the method
@return an array consisting of merged headers.
This merges built - in default headers user - specified default headers and method - specified headers . Method - specified take precedence over user defaults which take precedence over built - in defaults . The following headers are removed if found : " Content - length " . @param spec the headers specified in the call to the method @return an array consisting of merged headers .
private NVPair[] mergedHeaders(NVPair[] spec)
    {
	int spec_len = (spec != null ? spec.length : 0),
	    defs_len;
	NVPair[] merged;
	synchronized (DefaultHeaders)
	{
	    defs_len = (DefaultHeaders != null ? DefaultHeaders.length : 0);
	    merged   = new NVPair[spec_len + defs_len];
	    System.arraycopy(DefaultHeaders, 0, merged, 0, defs_len);
	}
	int sidx, didx = defs_len;
	for (sidx=0; sidx<spec_len; sidx++)
	{
	    if (spec[sidx] == null)
		continue;
	    String s_name = spec[sidx].getName().trim();
	    if (s_name.equalsIgnoreCase("Content-length"))
		continue;
	    int search;
	    for (search=0; search<didx; search++)
	    {
		if (merged[search].getName().trim().equalsIgnoreCase(s_name))
		    break;
	    }
	    merged[search] = spec[sidx];
	    if (search == didx) didx++;
	}
	if (didx < merged.length)
	    merged = Util.resizeArray(merged, didx);
	return merged;
    }
private NVPair [ ] mergedHeaders ( NVPair [ ] spec ) { int spec_len = ( spec != null ? spec . length : 0 ) , defs_len ; NVPair [ ] merged ; synchronized ( DefaultHeaders ) { defs_len = ( DefaultHeaders != null ? DefaultHeaders . length : 0 ) ; merged = new NVPair [ spec_len + defs_len ] ; System . arraycopy ( DefaultHeaders , 0 , merged , 0 , defs_len ) ; } int sidx , didx = defs_len ; for ( sidx = 0 ; sidx < spec_len ; sidx ++ ) { if ( spec [ sidx ] == null ) continue ; String s_name = spec [ sidx ] . getName ( ) . trim ( ) ; if ( s_name . equalsIgnoreCase ( "Content-length" ) ) continue ; int search ; for ( search = 0 ; search < didx ; search ++ ) { if ( merged [ search ] . getName ( ) . trim ( ) . equalsIgnoreCase ( s_name ) ) break ; } merged [ search ] = spec [ sidx ] ; if ( search == didx ) didx ++ ; } if ( didx < merged . length ) merged = Util . resizeArray ( merged , didx ) ; return merged ; }
This merges built-in default headers, user-specified default headers,
 and method-specified headers.
This merges built - in default headers user - specified default headers and method - specified headers .
// copy default headers // merge in selected headers