private void connected(ClientConnection conn) { checkThread(); conn.setCurrentRequest(this); this.conn = conn; // If anything was written or the request ended before we got the connection, then // we need to write it now if (pendingMaxSize != -1) { conn.setWriteQueueMaxSize(pendingMaxSize); } if (pendingChunks != null || writeHead || completed) { writeHead(); headWritten = true; } if (pendingChunks != null) { for (PendingChunk chunk : pendingChunks) { sendChunk(chunk.chunk, chunk.doneHandler); } } if (completed) { if (chunked) { writeEndChunk(); } conn.endRequest(); } }
// Raw request - used by websockets // Raw requests won't have any headers set automatically, like Content-Length and Connection HttpClientRequest( final HttpClient client, final String method, final String uri, final Handler<HttpClientResponse> respHandler, final Context context, final Thread th, final ClientConnection conn) { this(client, method, uri, respHandler, context, th, true); this.conn = conn; conn.setCurrentRequest(this); }
private void connected(ClientConnection conn) { conn.setCurrentRequest(this); this.conn = conn; this.metric = client .httpClientMetrics() .requestBegin(conn.metric(), conn.localAddress(), conn.remoteAddress(), this); // If anything was written or the request ended before we got the connection, then // we need to write it now if (pendingMaxSize != -1) { conn.doSetWriteQueueMaxSize(pendingMaxSize); } if (pendingChunks != null) { ByteBuf pending = pendingChunks; pendingChunks = null; if (completed) { // we also need to write the head so optimize this and write all out in once writeHeadWithContent(pending, true); conn.reportBytesWritten(written); if (respHandler != null) { conn.endRequest(); } } else { writeHeadWithContent(pending, false); } } else { if (completed) { // we also need to write the head so optimize this and write all out in once writeHeadWithContent(Unpooled.EMPTY_BUFFER, true); conn.reportBytesWritten(written); if (respHandler != null) { conn.endRequest(); } } else { if (writeHead) { writeHead(); } } } }