Source:
<code>public void run() { proxyThreadList.add(thread); boolean isSecure = this instanceof ProxyThreadSSL; HttpRequestHeader firstHeader = null; try { BufferedInputStream bufferedInputStream = new BufferedInputStream(inSocket.getInputStream(), 2048); inSocket = new CustomStreamsSocket(inSocket, bufferedInputStream, inSocket.getOutputStream()); httpIn = new HttpInputStream(inSocket); httpOut = new HttpOutputStream(inSocket.getOutputStream()); firstHeader = httpIn.readRequestHeader(isSecure); if (firstHeader.getMethod().equalsIgnoreCase(HttpRequestHeader.CONNECT)) { HttpMessage connectMsg = new HttpMessage(firstHeader); connectMsg.setTimeSentMillis(System.currentTimeMillis()); try { httpOut.write(CONNECT_HTTP_200); httpOut.flush(); connectMsg.setResponseHeader(CONNECT_HTTP_200); connectMsg.setTimeElapsedMillis((int) (System.currentTimeMillis() - connectMsg.getTimeSentMillis())); notifyConnectMessage(connectMsg); byte[] bytes = new byte[3]; bufferedInputStream.mark(3); bufferedInputStream.read(bytes); bufferedInputStream.reset(); if (isSslTlsHandshake(bytes)) { isSecure = true; beginSSL(firstHeader.getHostName()); } firstHeader = httpIn.readRequestHeader(isSecure); processHttp(firstHeader, isSecure); } catch (MissingRootCertificateException e) { final HttpMessage errmsg = new HttpMessage(firstHeader); setErrorResponse(errmsg, BAD_GATEWAY_RESPONSE_STATUS, e, "ZAP SSL Error"); writeHttpResponse(errmsg, httpOut); throw new IOException(e); } } else { processHttp(firstHeader, isSecure); } } catch (SocketTimeoutException e) { if (firstHeader != null) { log.warn("Timeout accessing " + firstHeader.getURI()); } else { <START> log.warn("Socket Timeout"); <END> if (log.isDebugEnabled()) { log.debug(e); } } } catch (HttpMalformedHeaderException e) { log.warn("Malformed Header: ", e); } catch (HttpException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.debug("IOException: ", e); } finally { proxyThreadList.remove(thread); if (!keepSocketOpen) { disconnect(); } } }</code><technical_language>Worth changing "Timed out while reading message.", this is a special case</technical_language>

Target:
public void run() { proxyThreadList.add(thread); boolean isSecure = this instanceof ProxyThreadSSL; HttpRequestHeader firstHeader = null; try { BufferedInputStream bufferedInputStream = new BufferedInputStream(inSocket.getInputStream(), 2048); inSocket = new CustomStreamsSocket(inSocket, bufferedInputStream, inSocket.getOutputStream()); httpIn = new HttpInputStream(inSocket); httpOut = new HttpOutputStream(inSocket.getOutputStream()); firstHeader = httpIn.readRequestHeader(isSecure); if (firstHeader.getMethod().equalsIgnoreCase(HttpRequestHeader.CONNECT)) { HttpMessage connectMsg = new HttpMessage(firstHeader); connectMsg.setTimeSentMillis(System.currentTimeMillis()); try { httpOut.write(CONNECT_HTTP_200); httpOut.flush(); connectMsg.setResponseHeader(CONNECT_HTTP_200); connectMsg.setTimeElapsedMillis((int) (System.currentTimeMillis() - connectMsg.getTimeSentMillis())); notifyConnectMessage(connectMsg); byte[] bytes = new byte[3]; bufferedInputStream.mark(3); bufferedInputStream.read(bytes); bufferedInputStream.reset(); if (isSslTlsHandshake(bytes)) { isSecure = true; beginSSL(firstHeader.getHostName()); } firstHeader = httpIn.readRequestHeader(isSecure); processHttp(firstHeader, isSecure); } catch (MissingRootCertificateException e) { final HttpMessage errmsg = new HttpMessage(firstHeader); setErrorResponse(errmsg, BAD_GATEWAY_RESPONSE_STATUS, e, "ZAP SSL Error"); writeHttpResponse(errmsg, httpOut); throw new IOException(e); } } else { processHttp(firstHeader, isSecure); } } catch (SocketTimeoutException e) { if (firstHeader != null) { log.warn("Timeout accessing " + firstHeader.getURI()); } else { log.warn("Socket timeout while reading first message."); if (log.isDebugEnabled()) { log.debug(e, e); } } } catch (HttpMalformedHeaderException e) { log.warn("Malformed Header: ", e); } catch (HttpException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.debug("IOException: ", e); } finally { proxyThreadList.remove(thread); if (!keepSocketOpen) { disconnect(); } } }