HttpMessage { public void setBody(@NotNull ByteBuf body) { if (CHECK) checkState(!isRecycled()); this.body = body; } protected  HttpMessage(); void addHeader(@NotNull HttpHeader header, @NotNull String string); void addHeader(@NotNull HttpHeader header, @NotNull byte[] value); void addHeader(@NotNull HttpHeader header, @NotNull byte[] array, int off, int len); void addHeader(@NotNull HttpHeader header, @NotNull HttpHeaderValue value); final Collection<Map.Entry<HttpHeader, HttpHeaderValue>> getHeaders(); @NotNull final List<T> getHeader(@NotNull HttpHeader header, @NotNull ParserIntoList<T> parser); @Nullable T getHeader(HttpHeader header, ParserFunction<ByteBuf, T> parser); @Nullable final String getHeader(@NotNull HttpHeader header); @Nullable final ByteBuf getHeaderBuf(@NotNull HttpHeader header); void addCookies(@NotNull HttpCookie... cookies); abstract void addCookies(@NotNull List<HttpCookie> cookies); abstract void addCookie(@NotNull HttpCookie cookie); void setBodyStream(@NotNull ChannelSupplier<ByteBuf> bodySupplier); ChannelSupplier<ByteBuf> getBodyStream(); void setBody(@NotNull ByteBuf body); void setBody(@NotNull byte[] body); final ByteBuf getBody(); final ByteBuf takeBody(); final boolean isBodyLoaded(); void setMaxBodySize(MemSize maxBodySize); void setMaxBodySize(int maxBodySize); Promise<ByteBuf> loadBody(); Promise<ByteBuf> loadBody(@NotNull MemSize maxBodySize); Promise<ByteBuf> loadBody(int maxBodySize); void attach(Type type, T extra); void attach(Class<T> type, T extra); void attach(Object extra); void attach(String key, T extra); @SuppressWarnings("unchecked") T getAttachment(Class<T> type); @SuppressWarnings("unchecked") T getAttachment(Type type); @SuppressWarnings("unchecked") T getAttachment(String key); Set<Object> getAttachmentKeys(); void setBodyGzipCompression();  }
@Test public void testHttpRequest() { assertHttpMessageEquals("GET /index.html HTTP/1.1\r\nHost: test.com\r\n\r\n", HttpRequest.get("http: assertHttpMessageEquals("POST /index.html HTTP/1.1\r\nHost: test.com\r\nContent-Length: 0\r\n\r\n", HttpRequest.post("http: assertHttpMessageEquals("CONNECT /index.html HTTP/1.1\r\nHost: test.com\r\n\r\n", HttpRequest.of(HttpMethod.CONNECT, "http: assertHttpMessageEquals("GET /index.html HTTP/1.1\r\nHost: test.com\r\nCookie: cookie1=value1\r\n\r\n", HttpRequest.get("http: assertHttpMessageEquals("GET /index.html HTTP/1.1\r\nHost: test.com\r\nCookie: cookie1=value1; cookie2=value2\r\n\r\n", HttpRequest.get("http: HttpRequest request = HttpRequest.post("http: ByteBuf buf = ByteBufPool.allocate(100); buf.put("/abc".getBytes(), 0, 4); request.setBody(buf); assertHttpMessageEquals("POST /index.html HTTP/1.1\r\nHost: test.com\r\nContent-Length: 4\r\n\r\n/abc", request); }