Skip to content

Commit

Permalink
Optimized headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jun 25, 2017
1 parent d50a190 commit 2daf797
Show file tree
Hide file tree
Showing 7 changed files with 696 additions and 11 deletions.
Expand Up @@ -30,6 +30,7 @@
import io.vertx.core.http.*; import io.vertx.core.http.*;
import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.impl.headers.VertxHttpHeaders;
import io.vertx.core.impl.ContextImpl; import io.vertx.core.impl.ContextImpl;
import io.vertx.core.impl.VertxInternal; import io.vertx.core.impl.VertxInternal;
import io.vertx.core.logging.Logger; import io.vertx.core.logging.Logger;
Expand Down Expand Up @@ -74,7 +75,7 @@ public class HttpServerResponseImpl implements HttpServerResponse {
private boolean chunked; private boolean chunked;
private boolean closed; private boolean closed;
private ChannelFuture channelFuture; private ChannelFuture channelFuture;
private MultiMap headers; private final VertxHttpHeaders headers;
private LastHttpContent trailing; private LastHttpContent trailing;
private MultiMap trailers; private MultiMap trailers;
private String statusMessage; private String statusMessage;
Expand All @@ -84,17 +85,15 @@ public class HttpServerResponseImpl implements HttpServerResponse {
this.vertx = vertx; this.vertx = vertx;
this.conn = conn; this.conn = conn;
this.version = request.getProtocolVersion(); this.version = request.getProtocolVersion();
this.response = new DefaultHttpResponse(version, HttpResponseStatus.OK, false); this.headers = new VertxHttpHeaders();
this.response = new DefaultHttpResponse(version, HttpResponseStatus.OK, headers);
this.keepAlive = (version == HttpVersion.HTTP_1_1 && !request.headers().contains(io.vertx.core.http.HttpHeaders.CONNECTION, HttpHeaders.CLOSE, true)) this.keepAlive = (version == HttpVersion.HTTP_1_1 && !request.headers().contains(io.vertx.core.http.HttpHeaders.CONNECTION, HttpHeaders.CLOSE, true))
|| (version == HttpVersion.HTTP_1_0 && request.headers().contains(io.vertx.core.http.HttpHeaders.CONNECTION, HttpHeaders.KEEP_ALIVE, true)); || (version == HttpVersion.HTTP_1_0 && request.headers().contains(io.vertx.core.http.HttpHeaders.CONNECTION, HttpHeaders.KEEP_ALIVE, true));
this.head = request.method() == io.netty.handler.codec.http.HttpMethod.HEAD; this.head = request.method() == io.netty.handler.codec.http.HttpMethod.HEAD;
} }


@Override @Override
public MultiMap headers() { public MultiMap headers() {
if (headers == null) {
headers = new HeadersAdaptor(response.headers());
}
return headers; return headers;
} }


Expand Down

0 comments on commit 2daf797

Please sign in to comment.