The fake CONNECT request generated to relay non-bumped traffic needs to
be pre-pended to any existing data in the ConnStateData::In buffer.
Otherwise our new bytes will corrupt any traffic bytes already in there
and our intended CONNECT request will never be recognised as we re-parse
the buffer.
// fake a CONNECT request to force connState to tunnel
static char ip[MAX_IPSTRLEN];
connState->clientConnection->local.toUrl(ip, sizeof(ip));
- // XXX need to *pre-pend* this fake request to the TLS bits already in the buffer
- connState->in.buf.append("CONNECT ").append(ip).append(" HTTP/1.1\r\nHost: ").append(ip).append("\r\n\r\n");
+ // Pre-pend this fake request to the TLS bits already in the buffer
+ SBuf retStr("CONNECT ").append(ip).append(" HTTP/1.1\r\nHost: ").append(ip).append("\r\n\r\n");
+ connState->in.buf = retStr.append(connState->in.buf);
bool ret = connState->handleReadData();
if (ret)
ret = connState->clientParseRequests();