@@ -26,53 +26,54 @@ public enum Protocol {
2626 public static boolean isHttpPacket (ByteBuf packet ) {
2727 int protocolEndIndex = IOUtil .indexOf (packet , HttpConstants .LF );
2828 if (protocolEndIndex == -1 && packet .readableBytes () > 7 ) {
29+ int readerIndex = packet .readerIndex ();
2930 // client multiple write packages. cause browser out of length.
30- if (packet .getByte (0 ) == 'G'
31- && packet .getByte (1 ) == 'E'
32- && packet .getByte (2 ) == 'T'
33- && packet .getByte (3 ) == ' '
34- && packet .getByte (4 ) == '/' ) {
31+ if (packet .getByte (readerIndex ) == 'G'
32+ && packet .getByte (readerIndex + 1 ) == 'E'
33+ && packet .getByte (readerIndex + 2 ) == 'T'
34+ && packet .getByte (readerIndex + 3 ) == ' '
35+ && packet .getByte (readerIndex + 4 ) == '/' ) {
3536 return true ;
36- } else if (packet .getByte (0 ) == 'P'
37- && packet .getByte (1 ) == 'O'
38- && packet .getByte (2 ) == 'S'
39- && packet .getByte (3 ) == 'T'
40- && packet .getByte (4 ) == ' '
41- && packet .getByte (5 ) == '/' ) {
37+ } else if (packet .getByte (readerIndex ) == 'P'
38+ && packet .getByte (readerIndex + 1 ) == 'O'
39+ && packet .getByte (readerIndex + 2 ) == 'S'
40+ && packet .getByte (readerIndex + 3 ) == 'T'
41+ && packet .getByte (readerIndex + 4 ) == ' '
42+ && packet .getByte (readerIndex + 5 ) == '/' ) {
4243 return true ;
43- } else if (packet .getByte (0 ) == 'O'
44- && packet .getByte (1 ) == 'P'
45- && packet .getByte (2 ) == 'T'
46- && packet .getByte (3 ) == 'I'
47- && packet .getByte (4 ) == 'O'
48- && packet .getByte (5 ) == 'N'
49- && packet .getByte (6 ) == 'S'
50- && packet .getByte (7 ) == ' '
51- && packet .getByte (8 ) == '/' ) {
44+ } else if (packet .getByte (readerIndex ) == 'O'
45+ && packet .getByte (readerIndex + 1 ) == 'P'
46+ && packet .getByte (readerIndex + 2 ) == 'T'
47+ && packet .getByte (readerIndex + 3 ) == 'I'
48+ && packet .getByte (readerIndex + 4 ) == 'O'
49+ && packet .getByte (readerIndex + 5 ) == 'N'
50+ && packet .getByte (readerIndex + 6 ) == 'S'
51+ && packet .getByte (readerIndex + 7 ) == ' '
52+ && packet .getByte (readerIndex + 8 ) == '/' ) {
5253 return true ;
53- } else if (packet .getByte (0 ) == 'P'
54- && packet .getByte (1 ) == 'U'
55- && packet .getByte (2 ) == 'T'
56- && packet .getByte (3 ) == ' '
57- && packet .getByte (4 ) == '/' ) {
54+ } else if (packet .getByte (readerIndex ) == 'P'
55+ && packet .getByte (readerIndex + 1 ) == 'U'
56+ && packet .getByte (readerIndex + 2 ) == 'T'
57+ && packet .getByte (readerIndex + 3 ) == ' '
58+ && packet .getByte (readerIndex + 4 ) == '/' ) {
5859 return true ;
59- } else if (packet .getByte (0 ) == 'D'
60- && packet .getByte (1 ) == 'E'
61- && packet .getByte (2 ) == 'L'
62- && packet .getByte (3 ) == 'E'
63- && packet .getByte (4 ) == 'T'
64- && packet .getByte (5 ) == 'E'
65- && packet .getByte (6 ) == ' '
66- && packet .getByte (7 ) == '/' ) {
60+ } else if (packet .getByte (readerIndex ) == 'D'
61+ && packet .getByte (readerIndex + 1 ) == 'E'
62+ && packet .getByte (readerIndex + 2 ) == 'L'
63+ && packet .getByte (readerIndex + 3 ) == 'E'
64+ && packet .getByte (readerIndex + 4 ) == 'T'
65+ && packet .getByte (readerIndex + 5 ) == 'E'
66+ && packet .getByte (readerIndex + 6 ) == ' '
67+ && packet .getByte (readerIndex + 7 ) == '/' ) {
6768 return true ;
6869 } else {
69- return packet .getByte (0 ) == 'P'
70- && packet .getByte (1 ) == 'A'
71- && packet .getByte (2 ) == 'T'
72- && packet .getByte (3 ) == 'C'
73- && packet .getByte (4 ) == 'H'
74- && packet .getByte (5 ) == ' '
75- && packet .getByte (6 ) == '/' ;
70+ return packet .getByte (readerIndex ) == 'P'
71+ && packet .getByte (readerIndex + 1 ) == 'A'
72+ && packet .getByte (readerIndex + 2 ) == 'T'
73+ && packet .getByte (readerIndex + 3 ) == 'C'
74+ && packet .getByte (readerIndex + 4 ) == 'H'
75+ && packet .getByte (readerIndex + 5 ) == ' '
76+ && packet .getByte (readerIndex + 6 ) == '/' ;
7677 }
7778 } else if (protocolEndIndex < 9 ) {
7879 return false ;
0 commit comments