Skip to content

Commit bb5764b

Browse files
committed
Remove HttpHeadersUtil
Motivation: HttpHeadersUtil methods were previously moved to HttpUtils in 4.1. However this class was not removed when merging from 4.1 to master. Modifications: - Remove HttpHeadersUtil Result: Less duplicate code.
1 parent a6816bd commit bb5764b

File tree

6 files changed

+22
-297
lines changed

6 files changed

+22
-297
lines changed

codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaderUtil.java

-277
This file was deleted.

codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Iterator;
2222
import java.util.List;
2323

24+
import static io.netty.util.AsciiString.c2b;
25+
2426
/**
2527
* Utility methods useful in the HTTP context.
2628
*/
@@ -188,7 +190,7 @@ public static long getContentLength(HttpMessage message, long defaultValue) {
188190
* a number. Not to exceed the boundaries of integer.
189191
*/
190192
public static int getContentLength(HttpMessage message, int defaultValue) {
191-
return (int) Math.min(Integer.MAX_VALUE, HttpHeaderUtil.getContentLength(message, (long) defaultValue));
193+
return (int) Math.min(Integer.MAX_VALUE, HttpUtil.getContentLength(message, (long) defaultValue));
192194
}
193195

194196
/**
@@ -319,8 +321,4 @@ static void encodeAscii0(CharSequence seq, ByteBuf buf) {
319321
buf.writeByte(c2b(seq.charAt(i)));
320322
}
321323
}
322-
323-
private static byte c2b(char c) {
324-
return c > 255 ? (byte) '?' : (byte) c;
325-
}
326324
}

codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import io.netty.handler.codec.http.DefaultFullHttpResponse;
2424
import io.netty.handler.codec.http.FullHttpRequest;
2525
import io.netty.handler.codec.http.HttpHeaderNames;
26-
import io.netty.handler.codec.http.HttpHeaderUtil;
2726
import io.netty.handler.codec.http.HttpRequest;
2827
import io.netty.handler.codec.http.HttpResponse;
28+
import io.netty.handler.codec.http.HttpUtil;
2929
import io.netty.handler.ssl.SslHandler;
3030

3131
import static io.netty.handler.codec.http.HttpMethod.*;
@@ -91,7 +91,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
9191

9292
private static void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
9393
ChannelFuture f = ctx.channel().writeAndFlush(res);
94-
if (!HttpHeaderUtil.isKeepAlive(req) || res.status().code() != 200) {
94+
if (!HttpUtil.isKeepAlive(req) || res.status().code() != 200) {
9595
f.addListener(ChannelFutureListener.CLOSE);
9696
}
9797
}

codec-http/src/test/java/io/netty/handler/codec/http/HttpContentCompressorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public void testEmptyFullContentWithTrailer() throws Exception {
296296
@Test
297297
public void test100Continue() throws Exception {
298298
FullHttpRequest request = newRequest();
299-
HttpHeaderUtil.set100ContinueExpected(request, true);
299+
HttpUtil.set100ContinueExpected(request, true);
300300

301301
EmbeddedChannel ch = new EmbeddedChannel(new HttpContentCompressor());
302302
ch.writeInbound(request);

example/src/main/java/io/netty/example/spdy/server/SpdyServerHandler.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@
2222
import io.netty.channel.SimpleChannelInboundHandler;
2323
import io.netty.handler.codec.http.DefaultFullHttpResponse;
2424
import io.netty.handler.codec.http.FullHttpResponse;
25-
import io.netty.handler.codec.http.HttpHeaderUtil;
2625
import io.netty.handler.codec.http.HttpHeaderValues;
2726
import io.netty.handler.codec.http.HttpRequest;
27+
import io.netty.handler.codec.http.HttpUtil;
2828
import io.netty.util.CharsetUtil;
2929

3030
import java.util.Date;
3131

32-
import static io.netty.handler.codec.http.HttpHeaderNames.*;
33-
import static io.netty.handler.codec.http.HttpResponseStatus.*;
34-
import static io.netty.handler.codec.http.HttpVersion.*;
32+
import static io.netty.handler.codec.http.HttpHeaderNames.CONNECTION;
33+
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH;
34+
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE;
35+
import static io.netty.handler.codec.http.HttpResponseStatus.CONTINUE;
36+
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
37+
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
3538

3639
/**
3740
* HTTP handler that responds with a "Hello World"
@@ -43,10 +46,10 @@ public void messageReceived(ChannelHandlerContext ctx, Object msg) {
4346
if (msg instanceof HttpRequest) {
4447
HttpRequest req = (HttpRequest) msg;
4548

46-
if (HttpHeaderUtil.is100ContinueExpected(req)) {
49+
if (HttpUtil.is100ContinueExpected(req)) {
4750
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE));
4851
}
49-
boolean keepAlive = HttpHeaderUtil.isKeepAlive(req);
52+
boolean keepAlive = HttpUtil.isKeepAlive(req);
5053

5154
ByteBuf content = Unpooled.copiedBuffer("Hello World " + new Date(), CharsetUtil.UTF_8);
5255

0 commit comments

Comments
 (0)