use of com.generallycloud.baseio.buffer.ByteBufAllocator in project baseio by generallycloud.
the class ClientHTTPProtocolEncoder method encode.
@Override
public void encode(SocketChannel channel, ChannelFuture future) throws IOException {
ByteBufAllocator allocator = channel.getByteBufAllocator();
HttpFuture f = (HttpFuture) future;
ByteBuf buf = allocator.allocate(256);
buf.put(f.getMethod().getBytes());
buf.putByte(SPACE);
buf.put(getRequestURI(f).getBytes());
buf.put(PROTOCOL);
writeHeaders(f, buf);
List<Cookie> cookieList = f.getCookieList();
if (cookieList != null && cookieList.size() > 0) {
buf.put(COOKIE);
for (Cookie c : cookieList) {
writeBuf(buf, c.getName().getBytes());
writeBuf(buf, COLON);
writeBuf(buf, c.getValue().getBytes());
writeBuf(buf, SEMICOLON);
}
buf.position(buf.position() - 1);
}
buf.put(RN);
future.setByteBuf(buf.flip());
}
Aggregations