Buggy code:
public class Proxy extends Thread { private static final Logger log = LoggingManager . getLoggerForClass ( ) ; private static final byte [ ] CRLF_BYTES = new byte [ ] { 13 , 10 } ; private static final String CRLF_STRING = "\r\n" ; private static final String NEW_LINE = "\n" ; private static final String [ ] headersToRemove ; private static final String PROXY_HEADERS_REMOVE = "proxy.headers.remove" ; private static final String PROXY_HEADERS_REMOVE_DEFAULT = "If-Modified-Since,If-None-Match,Host" ; private static final String PROXY_HEADERS_REMOVE_SEPARATOR = "," ; private static final String KEYSTORE_TYPE = JMeterUtils . getPropDefault ( "proxy.cert.type" , "JKS" ) ; private static final String KEYMANAGERFACTORY = JMeterUtils . getPropDefault ( "proxy.cert.factory" , "SunX509" ) ; private static final String SSLCONTEXT_PROTOCOL = JMeterUtils . getPropDefault ( "proxy.ssl.protocol" , "SSLv3" ) ; private static final HashMap < String , SSLSocketFactory > hashHost = new HashMap < String , SSLSocketFactory > ( ) ; private static final String CERT_DIRECTORY = JMeterUtils . getPropDefault ( "proxy.cert.directory" , JMeterUtils . getJMeterBinDir ( ) ) ; private static final String CERT_FILE_DEFAULT = "proxyserver.jks" ; private static final String CERT_FILE = JMeterUtils . getPropDefault ( "proxy.cert.file" , Proxy . CERT_FILE_DEFAULT ) ; private static final char [ ] KEYSTORE_PASSWORD = JMeterUtils . getPropDefault ( "proxy.cert.keystorepass" , "password" ) . toCharArray ( ) ; private static final char [ ] KEY_PASSWORD = JMeterUtils . getPropDefault ( "proxy.cert.keypassword" , "password" ) . toCharArray ( ) ; private static final SamplerCreatorFactory factory = new SamplerCreatorFactory ( ) ; private OutputStream outStreamClient = null ; private Socket clientSocket = null ; private ProxyControl target ; private boolean captureHttpHeaders ; private boolean httpsSpoof ; private String httpsSpoofMatch ; private Map < String , String > pageEncodings ; private Map < String , String > formEncodings ; public Proxy ( ) { } void configure ( Socket _clientSocket , ProxyControl _target , Map < String , String > _pageEncodings , Map < String , String > _formEncodings ) { } @ Override public void run ( ) { } private SSLSocketFactory getSSLSocketFactory ( String host ) throws IOException { } private Socket startSSL ( Socket sock , String host ) throws IOException { } private InputStream getCertificate ( ) { } private SampleResult generateErrorResult ( SampleResult result , Exception e ) { } private void writeToClient ( SampleResult res , OutputStream out , boolean forcedHTTPS ) throws IOException { } private String messageResponseHeaders ( SampleResult res , boolean forcedHTTPS ) { String headers = res . getResponseHeaders ( ) ; String [ ] headerLines = headers . split ( Proxy . NEW_LINE , 0 ) ; int contentLengthIndex = - 1 ; boolean fixContentLength = forcedHTTPS ; for ( int i = 0 ; i < ( headerLines . length ) ; i ++ ) { String line = headerLines [ i ] ; String [ ] parts = line . split ( ":\\s+" , 2 ) ; if ( ( parts . length ) == 2 ) { if ( TRANSFER_ENCODING . equalsIgnoreCase ( parts [ 0 ] ) ) { headerLines [ i ] = null ; continue ; } if ( ( HEADER_CONTENT_ENCODING . equalsIgnoreCase ( parts [ 0 ] ) ) && ( ENCODING_GZIP . equalsIgnoreCase ( parts [ 1 ] ) ) ) { headerLines [ i ] = null ; fixContentLength = true ; continue ; } if ( HEADER_CONTENT_LENGTH . equalsIgnoreCase ( parts [ 0 ] ) ) { contentLengthIndex = i ; continue ; } final String HTTPS_PREFIX = "https:////" ; if ( ( forcedHTTPS && ( HEADER_LOCATION . equalsIgnoreCase ( parts [ 0 ] ) ) ) && ( parts [ 1 ] . substring ( 0 , HTTPS_PREFIX . length ( ) ) . equalsIgnoreCase ( HTTPS_PREFIX ) ) ) { headerLines [ i ] = headerLines [ i ] . replaceFirst ( parts [ 1 ] . substring ( 0 , HTTPS_PREFIX . length ( ) ) , "http:////" ) ; continue ; } <START_BUG> if ( ( forcedHTTPS && ( HEADER_COOKIE . equalsIgnoreCase ( parts [ 0 ] ) ) ) || ( HEADER_SET_COOKIE . equalsIgnoreCase ( parts [ 0 ] ) ) ) { <END_BUG> headerLines [ i ] = headerLines [ i ] . replaceAll ( "<seq2seq4repair_space>secure" , "" ) . trim ( ) ; } } } if ( fixContentLength && ( contentLengthIndex >= 0 ) ) { headerLines [ contentLengthIndex ] = ( ( HTTPConstants . HEADER_CONTENT_LENGTH ) + ":<seq2seq4repair_space>" ) + ( res . getResponseData ( ) . length ) ; } StringBuilder sb = new StringBuilder ( headers . length ( ) ) ; for ( int i = 0 ; i < ( headerLines . length ) ; i ++ ) { String line = headerLines [ i ] ; if ( line != null ) { sb . append ( line ) . append ( Proxy . CRLF_STRING ) ; } } return sb . toString ( ) ; } private void writeErrorToClient ( String message ) { } private String addPageEncoding ( SampleResult result ) { } private void addFormEncodings ( SampleResult result , String pageEncoding ) { } private String getUrlWithoutQuery ( URL url ) { } }

Fix:
if ( forcedHTTPS && ( ( HEADER_COOKIE . equalsIgnoreCase ( parts [ 0 ] ) ) || ( HEADER_SET_COOKIE . equalsIgnoreCase ( parts [ 0 ] ) ) ) ) {