public HttpRequest build() {
if (url == null) {
throw new IllegalStateException("URL not set");
}
URL u = getURL();
String uri = u.getPathAndQuery();
if (uri.isEmpty()) {
uri = "/";
}
HttpMethod mth = HttpMethod.valueOf(method.name());
DefaultHttpRequest h = body == null
? new DefaultHttpRequest(version, mth, uri)
: new DefaultFullHttpRequest(version, mth, uri, body);
for (Entry<?> e : entries) {
e.addTo(h.headers());
}
if (!noHostHeader) {
h.headers().add(HttpHeaders.Names.HOST, u.getHost().toString());
}
if (!h.headers().contains(HttpHeaders.Names.CONNECTION) && !noConnectionHeader) {
h.headers().add(HttpHeaders.Names.CONNECTION, "close");
}
if (!noDateHeader) {