From 160866e1a009a52ec37a8023f9e5aa1c68b04a3a Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 15 Jun 2009 07:30:07 +0000 Subject: [PATCH] HttpMessageDecoder does not use regular expressions to decode the initial line and headers anymore so that it performs better --- .../codec/http/HttpMessageDecoder.java | 94 +++++++++++++++---- 1 file changed, 76 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java index 4a1a6a29dd..d6fe88e956 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java @@ -22,8 +22,6 @@ package org.jboss.netty.handler.codec.http; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -42,11 +40,6 @@ import org.jboss.netty.handler.codec.replay.ReplayingDecoder; */ public abstract class HttpMessageDecoder extends ReplayingDecoder { - private static final Pattern INITIAL_PATTERN = Pattern.compile( - "^\\s*(\\S+)\\s+(\\S+)\\s+(.*)\\s*$"); - private static final Pattern HEADER_PATTERN = Pattern.compile( - "^\\s*(\\S+)\\s*:\\s*(.*)\\s*$"); - private final int maxInitialLineLength; private final int maxHeaderSize; private final int maxChunkSize; @@ -495,20 +488,85 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder 0; result --) { + if (!Character.isWhitespace(sb.charAt(result - 1))) { + break; + } + } + return result; } }