newResponse = new SIPResponse(); try { newResponse.setStatusCode(statusCode); } catch (ParseException ex) { throw new IllegalArgumentException("Bad code " + statusCode); } if (reasonPhrase != null) newResponse.setReasonPhrase(reasonPhrase); else newResponse.setReasonPhrase( SIPResponse.getReasonPhrase(statusCode)); headerIterator = getHeaders(); while (headerIterator.hasNext()) { nextHeader = (SIPHeader) headerIterator.next(); if (nextHeader instanceof From || nextHeader instanceof To || nextHeader instanceof ViaList || nextHeader instanceof CallID || nextHeader instanceof RecordRouteList || nextHeader instanceof CSeq || nextHeader instanceof MaxForwards || nextHeader instanceof TimeStamp) {  try { newResponse.attachHeader(nextHeader, false); } catch (SIPDuplicateHeaderException e) { e.printStackTrace(); } } } return newResponse;
String reasonPhrase = SIPResponse.getReasonPhrase(statusCode); return this.createResponse(statusCode, reasonPhrase);
	public SIPResponse createResponse(int statusCode, String reasonPhrase) {		SIPResponse newResponse;		Iterator headerIterator;		SIPHeader nextHeader;		newResponse = new SIPResponse();		try {			newResponse.setStatusCode(statusCode);		} catch (ParseException ex) {			throw new IllegalArgumentException("Bad code " + statusCode);		}		if (reasonPhrase != null)			newResponse.setReasonPhrase(reasonPhrase);		else			newResponse.setReasonPhrase(				SIPResponse.getReasonPhrase(statusCode));		headerIterator = getHeaders();		while (headerIterator.hasNext()) {			nextHeader = (SIPHeader) headerIterator.next();			if (nextHeader instanceof From				|| nextHeader instanceof To				|| nextHeader instanceof ViaList				|| nextHeader instanceof CallID				|| nextHeader instanceof RecordRouteList				|| nextHeader instanceof CSeq				|| nextHeader instanceof MaxForwards				|| // nextHeader instanceof ExtensionHeader 	||			nextHeader					instanceof TimeStamp) {				/**				if (SIPMessage.isRequestHeader(nextHeader)) {					continue;				} else if (nextHeader instanceof ContentLength) {					// content length added when content is					// added...					continue;				} else if ( nextHeader instanceof ContactList)  {				       // contacts are stripped from the response.					continue;				}				**/				try {					newResponse.attachHeader(nextHeader, false);				} catch (SIPDuplicateHeaderException e) {					e.printStackTrace();				}			}		}		return newResponse;	}