public GrizzlyResponse(final HttpResponsePacket httpResponsePacket, final HttpResponseStatus status, final HttpResponseHeaders headers, final List<HttpResponseBodyPart> bodyParts) { super(status, headers, bodyParts); this.httpResponsePacket = httpResponsePacket; if (isNonEmpty(bodyParts)) { if (bodyParts.size() == 1) { responseBody = ((GrizzlyResponseBodyPart) bodyParts.get(0)).getBodyBuffer(); } else { final Buffer firstBuffer = ((GrizzlyResponseBodyPart) bodyParts.get(0)).getBodyBuffer(); final MemoryManager mm = httpResponsePacket.getRequest().getConnection().getMemoryManager(); Buffer constructedBodyBuffer = firstBuffer; for (int i = 1, len = bodyParts.size(); i < len; i++) { constructedBodyBuffer = Buffers.appendBuffers(mm, constructedBodyBuffer, ((GrizzlyResponseBodyPart) bodyParts.get(i)).getBodyBuffer()); } responseBody = constructedBodyBuffer; } } else { responseBody = Buffers.EMPTY_BUFFER; } }
public TransformerInput(Transformer<Buffer, Buffer> transformer, Input underlyingInput, Connection connection) { this(transformer, underlyingInput, connection.getMemoryManager(), connection); }
public TransformerInput(Transformer<Buffer, Buffer> transformer, Input underlyingInput, Connection connection) { this(transformer, underlyingInput, connection.getMemoryManager(), connection); }
public TransformerInput(Transformer<Buffer, Buffer> transformer, Input underlyingInput, Connection connection) { this(transformer, underlyingInput, connection.getMemoryManager(), connection); }
protected MemoryManager obtainMemoryManager(AttributeStorage storage) { if (memoryManager != null) { return memoryManager; } if (storage instanceof Connection) { Connection connection = (Connection) storage; return connection.getMemoryManager(); } return MemoryManager.DEFAULT_MEMORY_MANAGER; }
protected MemoryManager obtainMemoryManager(AttributeStorage storage) { if (memoryManager != null) { return memoryManager; } if (storage instanceof Connection) { Connection connection = (Connection) storage; return connection.getMemoryManager(); } return MemoryManager.DEFAULT_MEMORY_MANAGER; }
public TransformerOutput(Transformer<Buffer, Buffer> transformer, Output underlyingOutput, Connection connection) { this(transformer, underlyingOutput, connection.getMemoryManager(), connection); }
public TransformerInput(Transformer<Buffer, Buffer> transformer, Input underlyingInput, Connection connection) { this(transformer, underlyingInput, connection.getMemoryManager(), connection); }
public TransformerOutput(Transformer<Buffer, Buffer> transformer, Output underlyingOutput, Connection connection) { this(transformer, underlyingOutput, connection.getMemoryManager(), connection); }
/** * <p>A simple alias for <code>FilterChainContext.getConnection().getMemoryManager()</code>. * * @return the {@link MemoryManager} associated with the {@link Connection} * of this <code>FilterChainContext</code>. */ public final MemoryManager getMemoryManager() { return getConnection().getMemoryManager(); }
/** * <p>A simple alias for <code>FilterChainContext.getConnection().getMemoryManager()</code>. * * @return the {@link MemoryManager} associated with the {@link Connection} * of this <code>FilterChainContext</code>. */ public final MemoryManager getMemoryManager() { return getConnection().getMemoryManager(); }
/** * <p>A simple alias for <code>FilterChainContext.getConnection().getMemoryManager()</code>. * * @return the {@link MemoryManager} associated with the {@link Connection} * of this <code>FilterChainContext</code>. */ public final MemoryManager getMemoryManager() { return getConnection().getMemoryManager(); }
/** * <p>A simple alias for <code>FilterChainContext.getConnection().getMemoryManager()</code>. * * @return the {@link MemoryManager} associated with the {@link Connection} * of this <code>FilterChainContext</code>. */ public final MemoryManager getMemoryManager() { return getConnection().getMemoryManager(); }
private void flushBufferedData() { if (buffer.size() == 0) { // buffer is empty return; } Buffer message = Buffers.wrap(grizzlyConnection.getMemoryManager(), buffer.toByteArray()); grizzlyConnection.write(message); buffer.reset(); } }
@Override public Buffer clone(final Connection connection, final Buffer originalMessage) { // Buffer was disposed somewhere on the way to async write queue - // just return the original message if (temporaryWriteBuffer.isDisposed()) { return originalMessage; } return clone0(connection.getMemoryManager(), originalMessage); }
/** * {@inheritDoc} */ @Override public void writeByteArray(byte[] data, int offset, int length) throws IOException { final Buffer buffer = Buffers.wrap(connection.getMemoryManager(), data, offset, length); output.write(buffer); }
/** * {@inheritDoc} */ @Override public void writeByteArray(byte[] data, int offset, int length) throws IOException { final Buffer buffer = Buffers.wrap(connection.getMemoryManager(), data, offset, length); output.write(buffer); }
/** * {@inheritDoc} */ @Override public void writeByteArray(byte[] data, int offset, int length) throws IOException { final Buffer buffer = Buffers.wrap(connection.getMemoryManager(), data, offset, length); output.write(buffer); }
@Override @SuppressWarnings("unchecked") public Buffer grow(final SSLConnectionContext sslCtx, final Buffer oldBuffer, final int newSize) { final MemoryManager mm = sslCtx.getConnection().getMemoryManager(); return oldBuffer == null ? mm.allocate(newSize) : mm.reallocate(oldBuffer, newSize); } };
@Before public void setUp() { HttpEntity entity = new ByteArrayHttpEntity(new byte[1]); responseMock = mock(HttpResponse.class); when(request.getProtocol()).thenReturn(HTTP_1_1); when(responseMock.getEntity()).thenReturn(entity); when(ctx.getConnection()).thenReturn(connection); when(connection.getMemoryManager()).thenReturn(null); when(ctx.getMemoryManager()).thenReturn(null); }