Mercurial Hosting > luan
annotate src/org/eclipse/jetty/http/HttpParser.java @ 1041:35e3c864d7a7
make View package local
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 04 Nov 2016 00:47:23 -0600 |
parents | b71ad168fe34 |
children | dd71a59fcf72 |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.http; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import java.io.IOException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import org.eclipse.jetty.io.Buffer; |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
24 import org.eclipse.jetty.io.ByteArrayBuffer; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import org.eclipse.jetty.io.BufferUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import org.eclipse.jetty.io.EndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import org.eclipse.jetty.io.EofException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import org.eclipse.jetty.util.StringUtil; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
29 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
30 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 |
979 | 32 public final class HttpParser |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 { |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
34 private static final Logger LOG = LoggerFactory.getLogger(HttpParser.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
36 // States |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
37 private static final int STATE_START = -14; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
38 private static final int STATE_FIELD0 = -13; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
39 private static final int STATE_SPACE1 = -12; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
40 private static final int STATE_STATUS = -11; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
41 private static final int STATE_URI = -10; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
42 private static final int STATE_SPACE2 = -9; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
43 private static final int STATE_FIELD2 = -6; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
44 private static final int STATE_HEADER = -5; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
45 private static final int STATE_HEADER_NAME = -4; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
46 private static final int STATE_HEADER_IN_NAME = -3; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
47 private static final int STATE_HEADER_VALUE = -2; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
48 private static final int STATE_HEADER_IN_VALUE = -1; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
49 private static final int STATE_END = 0; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
50 private static final int STATE_EOF_CONTENT = 1; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
51 private static final int STATE_CONTENT = 2; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
52 private static final int STATE_CHUNKED_CONTENT = 3; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
53 private static final int STATE_CHUNK_SIZE = 4; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
54 private static final int STATE_CHUNK_PARAMS = 5; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
55 private static final int STATE_CHUNK = 6; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
56 private static final int STATE_SEEKING_EOF = 7; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
57 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
58 private final EventHandler _handler; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
59 private final EndPoint _endp; |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
60 public final Buffer _header; // Buffer for header data (and small _content) |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
61 private final Buffer _body; // Buffer for large content |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
62 private Buffer _buffer; // The current buffer in use (either _header or _content) |
1022
3718afd99988
HttpHeaders uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1021
diff
changeset
|
63 private String _cached; |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
64 private String _tok0 = ""; // Saved token: header name, request method or response version |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
65 private String _tok1 = ""; // Saved token: header value, request URI or response code |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
66 private String _multiLineValue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
67 private int _responseStatus; // If >0 then we are parsing a response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
68 private boolean _persistent; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
69 |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
70 private Buffer _contentView = new ByteArrayBuffer(0); // View of the content in the buffer for {@link Input} |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
71 private int _state = STATE_START; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
72 private byte _eol; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
73 private int _length; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
74 private long _contentLength; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
75 private long _contentPosition; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
76 private int _chunkLength; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
77 private int _chunkPosition; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
78 private boolean _headResponse; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
79 |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
80 public HttpParser(Buffer headerBuffer,Buffer bodyBuffer, EndPoint endp, EventHandler handler) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
81 { |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
82 _header = headerBuffer; |
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
83 _body = bodyBuffer; |
980 | 84 _endp = endp; |
85 _handler = handler; | |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
86 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
87 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
88 public long getContentLength() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
89 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
90 return _contentLength; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
91 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
92 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
93 public long getContentRead() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
94 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
95 return _contentPosition; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
96 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
97 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
98 /* ------------------------------------------------------------ */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
99 /** Set if a HEAD response is expected |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
100 * @param head |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
101 */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
102 public void setHeadResponse(boolean head) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
103 { |
980 | 104 _headResponse = head; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
105 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
106 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
107 public boolean isChunking() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
108 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
109 return _contentLength==HttpTokens.CHUNKED_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
110 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
111 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
112 public boolean isIdle() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
113 { |
980 | 114 return _state==STATE_START; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
115 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
116 |
980 | 117 public boolean isComplete() |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
118 { |
980 | 119 return _state==STATE_END; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
120 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
121 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
122 public boolean isPersistent() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
123 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
124 return _persistent; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
125 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
126 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
127 public void setPersistent(boolean persistent) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
128 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
129 _persistent = persistent; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
130 if (!_persistent &&(_state==STATE_END || _state==STATE_START)) |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
131 _state = STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
132 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
133 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
134 /* ------------------------------------------------------------------------------- */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
135 /** |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
136 * Parse until END state. |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
137 * This method will parse any remaining content in the current buffer as long as there is |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
138 * no unconsumed content. It does not care about the {@link #getState current state} of the parser. |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
139 * @see #parse |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
140 * @see #parseNext |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
141 */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
142 public boolean parseAvailable() throws IOException |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
143 { |
1001 | 144 boolean progress = parseNext() > 0; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
145 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
146 // continue parsing |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
147 while (!isComplete() && _buffer!=null && _buffer.remaining()>0 && !_contentView.hasRemaining()) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
148 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
149 progress |= parseNext()>0; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
150 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
151 return progress; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
152 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
153 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
154 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
155 /* ------------------------------------------------------------------------------- */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
156 /** |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
157 * Parse until next Event. |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
158 * @return an indication of progress <0 EOF, 0 no progress, >0 progress. |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
159 */ |
980 | 160 private int parseNext() throws IOException |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
161 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
162 try |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
163 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
164 int progress=0; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
165 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
166 if (_state == STATE_END) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
167 return 0; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
168 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
169 if (_buffer==null) |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
170 _buffer = _header; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
171 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
172 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
173 if (_state == STATE_CONTENT && _contentPosition == _contentLength) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
174 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
175 _state=STATE_END; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
176 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
177 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
178 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
179 |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
180 int length = _buffer.remaining(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
181 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
182 // Fill buffer if we can |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
183 if (length == 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
184 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
185 int filled=-1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
186 IOException ex=null; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
187 try |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
188 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
189 filled=fill(); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
190 LOG.debug("filled {}/{}",filled,_buffer.remaining()); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
191 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
192 catch(IOException e) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
193 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
194 LOG.debug(this.toString(),e); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
195 ex=e; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
196 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
197 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
198 if (filled > 0 ) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
199 progress++; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
200 else if (filled < 0 ) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
201 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
202 _persistent = false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
203 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
204 // do we have content to deliver? |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
205 if (_state>STATE_END) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
206 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
207 if (_buffer.remaining()>0 && !_headResponse) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
208 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
209 Buffer chunk = _buffer.get(_buffer.remaining()); |
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
210 _contentPosition += chunk.remaining(); |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
211 _contentView = chunk; |
1036 | 212 _handler.content(); // May recurse here |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
213 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
214 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
215 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
216 // was this unexpected? |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
217 switch(_state) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
218 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
219 case STATE_END: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
220 case STATE_SEEKING_EOF: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
221 _state=STATE_END; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
222 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
223 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
224 case STATE_EOF_CONTENT: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
225 _state=STATE_END; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
226 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
227 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
228 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
229 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
230 _state=STATE_END; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
231 if (!_headResponse) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
232 _handler.earlyEOF(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
233 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
234 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
235 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
236 if (ex!=null) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
237 throw ex; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
238 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
239 if (!isComplete() && !isIdle()) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
240 throw new EofException(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
241 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
242 return -1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
243 } |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
244 length=_buffer.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
245 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
246 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
247 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
248 // Handle header states |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
249 byte ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
250 byte[] array=_buffer.array(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
251 int last=_state; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
252 while (_state<STATE_END && length-->0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
253 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
254 if (last!=_state) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
255 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
256 progress++; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
257 last=_state; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
258 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
259 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
260 ch=_buffer.get(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
261 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
262 if (_eol == HttpTokens.CARRIAGE_RETURN) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
263 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
264 if (ch == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
265 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
266 _eol=HttpTokens.LINE_FEED; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
267 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
268 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
269 throw new HttpException(HttpStatus.BAD_REQUEST_400); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
270 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
271 _eol=0; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
272 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
273 switch (_state) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
274 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
275 case STATE_START: |
1021 | 276 _contentLength = HttpTokens.UNKNOWN_CONTENT; |
277 _cached = null; | |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
278 if (ch > HttpTokens.SPACE || ch<0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
279 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
280 _buffer.mark(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
281 _state=STATE_FIELD0; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
282 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
283 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
284 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
285 case STATE_FIELD0: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
286 if (ch == HttpTokens.SPACE) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
287 { |
1032 | 288 _tok0 = _buffer.toString(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex()); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
289 _responseStatus = !HttpVersions.CACHE.contains(_tok0)?-1:0; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
290 _state=STATE_SPACE1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
291 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
292 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
293 else if (ch < HttpTokens.SPACE && ch>=0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
294 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
295 throw new HttpException(HttpStatus.BAD_REQUEST_400); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
296 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
297 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
298 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
299 case STATE_SPACE1: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
300 if (ch > HttpTokens.SPACE || ch<0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
301 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
302 _buffer.mark(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
303 if (_responseStatus>=0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
304 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
305 _state = STATE_STATUS; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
306 _responseStatus=ch-'0'; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
307 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
308 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
309 _state=STATE_URI; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
310 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
311 else if (ch < HttpTokens.SPACE) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
312 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
313 throw new HttpException(HttpStatus.BAD_REQUEST_400); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
314 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
315 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
316 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
317 case STATE_STATUS: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
318 if (ch == HttpTokens.SPACE) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
319 { |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
320 // _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1); |
1032 | 321 _tok1 = _buffer.toString(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex()); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
322 _state = STATE_SPACE2; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
323 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
324 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
325 else if (ch>='0' && ch<='9') |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
326 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
327 _responseStatus=_responseStatus*10+(ch-'0'); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
328 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
329 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
330 else if (ch < HttpTokens.SPACE && ch>=0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
331 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
332 _eol=ch; |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
333 _state = STATE_HEADER; |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
334 _tok0 = ""; |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
335 _tok1 = ""; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
336 _multiLineValue=null; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
337 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
338 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
339 // not a digit, so must be a URI |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
340 _state=STATE_URI; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
341 _responseStatus=-1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
342 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
343 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
344 case STATE_URI: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
345 if (ch == HttpTokens.SPACE) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
346 { |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
347 // _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1); |
1032 | 348 _tok1 = _buffer.toString(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex()); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
349 _state=STATE_SPACE2; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
350 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
351 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
352 else if (ch < HttpTokens.SPACE && ch>=0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
353 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
354 // HTTP/0.9 |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
355 _handler.startRequest(_tok0, _buffer.sliceFromMark().toString(), null); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
356 _persistent = false; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
357 _state = STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
358 _handler.headerComplete(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
359 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
360 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
361 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
362 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
363 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
364 case STATE_SPACE2: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
365 if (ch > HttpTokens.SPACE || ch<0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
366 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
367 _buffer.mark(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
368 _state=STATE_FIELD2; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
369 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
370 else if (ch < HttpTokens.SPACE) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
371 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
372 if (_responseStatus>0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
373 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
374 _eol=ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
375 _state=STATE_HEADER; |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
376 _tok0 = ""; |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
377 _tok1 = ""; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
378 _multiLineValue=null; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
379 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
380 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
381 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
382 // HTTP/0.9 |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
383 _handler.startRequest(_tok0, _tok1, null); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
384 _persistent = false; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
385 _state = STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
386 _handler.headerComplete(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
387 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
388 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
389 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
390 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
391 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
392 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
393 case STATE_FIELD2: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
394 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
395 { |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
396 String version; |
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
397 if (_responseStatus > 0) |
980 | 398 // _handler.startResponse(version=HttpVersions.CACHE.lookup(_tok0), _responseStatus,_buffer.sliceFromMark()); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
399 version = _tok0; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
400 else |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
401 _handler.startRequest(_tok0, _tok1, version=_buffer.sliceFromMark().toString()); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
402 _eol=ch; |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
403 _persistent = HttpVersions.CACHE.getOrdinal(version) >= HttpVersions.HTTP_1_1_ORDINAL; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
404 _state=STATE_HEADER; |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
405 _tok0 = ""; |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
406 _tok1 = ""; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
407 _multiLineValue=null; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
408 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
409 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
410 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
411 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
412 case STATE_HEADER: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
413 switch(ch) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
414 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
415 case HttpTokens.COLON: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
416 case HttpTokens.SPACE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
417 case HttpTokens.TAB: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
418 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
419 // header value without name - continuation? |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
420 _length=-1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
421 _state=STATE_HEADER_VALUE; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
422 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
423 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
424 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
425 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
426 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
427 // handler last header if any |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
428 if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
429 { |
1022
3718afd99988
HttpHeaders uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1021
diff
changeset
|
430 String header = _cached!=null ? _cached : _tok0; |
1021 | 431 _cached = null; |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
432 String value = _multiLineValue == null ? _tok1 : _multiLineValue; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
433 |
1021 | 434 int ho = HttpHeaders.CACHE.getOrdinal(header); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
435 if (ho >= 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
436 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
437 int vo; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
438 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
439 switch (ho) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
440 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
441 case HttpHeaders.CONTENT_LENGTH_ORDINAL: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
442 if (_contentLength != HttpTokens.CHUNKED_CONTENT ) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
443 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
444 try |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
445 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
446 _contentLength=BufferUtil.toLong(value); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
447 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
448 catch(NumberFormatException e) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
449 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
450 LOG.trace("",e); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
451 throw new HttpException(HttpStatus.BAD_REQUEST_400); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
452 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
453 if (_contentLength <= 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
454 _contentLength=HttpTokens.NO_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
455 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
456 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
457 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
458 case HttpHeaders.TRANSFER_ENCODING_ORDINAL: |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
459 // value=HttpHeaderValues.CACHE.lookup(value); |
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
460 vo = HttpHeaderValues.CACHE.getOrdinal(value); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
461 if (HttpHeaderValues.CHUNKED_ORDINAL == vo) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
462 _contentLength=HttpTokens.CHUNKED_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
463 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
464 { |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
465 if (value.endsWith(HttpHeaderValues.CHUNKED)) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
466 _contentLength=HttpTokens.CHUNKED_CONTENT; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
467 |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
468 else if (value.indexOf(HttpHeaderValues.CHUNKED) >= 0) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
469 throw new HttpException(400,null); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
470 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
471 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
472 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
473 case HttpHeaders.CONNECTION_ORDINAL: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
474 switch(HttpHeaderValues.CACHE.getOrdinal(value)) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
475 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
476 case HttpHeaderValues.CLOSE_ORDINAL: |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
477 _persistent = false; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
478 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
479 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
480 case HttpHeaderValues.KEEP_ALIVE_ORDINAL: |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
481 _persistent = true; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
482 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
483 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
484 case -1: // No match, may be multi valued |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
485 { |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
486 for (String v : value.split(",")) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
487 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
488 switch(HttpHeaderValues.CACHE.getOrdinal(v.trim())) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
489 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
490 case HttpHeaderValues.CLOSE_ORDINAL: |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
491 _persistent = false; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
492 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
493 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
494 case HttpHeaderValues.KEEP_ALIVE_ORDINAL: |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
495 _persistent = true; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
496 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
497 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
498 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
499 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
500 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
501 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
502 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
503 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
504 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
505 _handler.parsedHeader(header, value); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
506 _tok0 = ""; |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
507 _tok1 = ""; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
508 _multiLineValue=null; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
509 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
510 _buffer.setMarkIndex(-1); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
511 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
512 // now handle ch |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
513 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
514 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
515 // is it a response that cannot have a body? |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
516 if (_responseStatus > 0 && // response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
517 (_responseStatus == 304 || // not-modified response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
518 _responseStatus == 204 || // no-content response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
519 _responseStatus < 200)) // 1xx response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
520 _contentLength=HttpTokens.NO_CONTENT; // ignore any other headers set |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
521 // else if we don't know framing |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
522 else if (_contentLength == HttpTokens.UNKNOWN_CONTENT) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
523 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
524 if (_responseStatus == 0 // request |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
525 || _responseStatus == 304 // not-modified response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
526 || _responseStatus == 204 // no-content response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
527 || _responseStatus < 200) // 1xx response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
528 _contentLength=HttpTokens.NO_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
529 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
530 _contentLength=HttpTokens.EOF_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
531 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
532 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
533 _contentPosition=0; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
534 _eol=ch; |
1037
3c4c7cc7904f
rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
535 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
536 _eol=_buffer.get(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
537 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
538 // We convert _contentLength to an int for this switch statement because |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
539 // we don't care about the amount of data available just whether there is some. |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
540 switch (_contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) _contentLength) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
541 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
542 case HttpTokens.EOF_CONTENT: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
543 _state=STATE_EOF_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
544 _handler.headerComplete(); // May recurse here ! |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
545 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
546 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
547 case HttpTokens.CHUNKED_CONTENT: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
548 _state=STATE_CHUNKED_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
549 _handler.headerComplete(); // May recurse here ! |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
550 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
551 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
552 case HttpTokens.NO_CONTENT: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
553 _handler.headerComplete(); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
554 _state = _persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
555 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
556 return 1; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
557 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
558 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
559 _state=STATE_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
560 _handler.headerComplete(); // May recurse here ! |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
561 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
562 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
563 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
564 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
565 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
566 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
567 // New header |
1021 | 568 _length = 1; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
569 _buffer.mark(); |
1021 | 570 _state = STATE_HEADER_NAME; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
571 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
572 // try cached name! |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
573 if (array!=null) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
574 { |
1022
3718afd99988
HttpHeaders uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1021
diff
changeset
|
575 String s = new String(array, _buffer.markIndex(), length+1); |
3718afd99988
HttpHeaders uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1021
diff
changeset
|
576 _cached = HttpHeaders.CACHE.getBest(s); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
577 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
578 if (_cached!=null) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
579 { |
1021 | 580 _length = _cached.length(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
581 _buffer.setGetIndex(_buffer.markIndex()+_length); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
582 length = _buffer.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
583 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
584 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
585 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
586 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
587 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
588 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
589 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
590 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
591 case STATE_HEADER_NAME: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
592 switch(ch) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
593 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
594 case HttpTokens.CARRIAGE_RETURN: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
595 case HttpTokens.LINE_FEED: |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
596 if (_length > 0) { |
1032 | 597 _tok0 = _buffer.toString(_buffer.markIndex(), _length); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
598 } |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
599 _eol=ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
600 _state=STATE_HEADER; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
601 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
602 case HttpTokens.COLON: |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
603 if (_length > 0 && _cached==null) { |
1032 | 604 _tok0 = _buffer.toString(_buffer.markIndex(), _length); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
605 } |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
606 _length=-1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
607 _state=STATE_HEADER_VALUE; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
608 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
609 case HttpTokens.SPACE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
610 case HttpTokens.TAB: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
611 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
612 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
613 { |
1021 | 614 _cached = null; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
615 if (_length == -1) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
616 _buffer.mark(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
617 _length=_buffer.getIndex() - _buffer.markIndex(); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
618 _state = STATE_HEADER_IN_NAME; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
619 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
620 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
621 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
622 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
623 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
624 case STATE_HEADER_IN_NAME: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
625 switch(ch) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
626 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
627 case HttpTokens.CARRIAGE_RETURN: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
628 case HttpTokens.LINE_FEED: |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
629 if (_length > 0) { |
1032 | 630 _tok0 = _buffer.toString(_buffer.markIndex(),_length); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
631 } |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
632 _eol=ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
633 _state=STATE_HEADER; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
634 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
635 case HttpTokens.COLON: |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
636 if (_length > 0 && _cached==null) { |
1032 | 637 _tok0 = _buffer.toString(_buffer.markIndex(),_length); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1017
diff
changeset
|
638 } |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
639 _length=-1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
640 _state=STATE_HEADER_VALUE; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
641 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
642 case HttpTokens.SPACE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
643 case HttpTokens.TAB: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
644 _state=STATE_HEADER_NAME; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
645 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
646 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
647 { |
1021 | 648 _cached = null; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
649 _length++; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
650 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
651 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
652 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
653 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
654 case STATE_HEADER_VALUE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
655 switch(ch) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
656 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
657 case HttpTokens.CARRIAGE_RETURN: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
658 case HttpTokens.LINE_FEED: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
659 if (_length > 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
660 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
661 if (_tok1.length() == 0) |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
662 // _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); |
1032 | 663 _tok1 = _buffer.toString(_buffer.markIndex(), _length); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
664 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
665 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
666 // Continuation line! |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
667 if (_multiLineValue == null) _multiLineValue = _tok1; |
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
668 // _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); |
1032 | 669 _tok1 = _buffer.toString(_buffer.markIndex(), _length); |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
670 _multiLineValue += " " + _tok1; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
671 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
672 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
673 _eol=ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
674 _state=STATE_HEADER; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
675 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
676 case HttpTokens.SPACE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
677 case HttpTokens.TAB: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
678 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
679 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
680 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
681 if (_length == -1) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
682 _buffer.mark(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
683 _length=_buffer.getIndex() - _buffer.markIndex(); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
684 _state = STATE_HEADER_IN_VALUE; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
685 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
686 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
687 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
688 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
689 case STATE_HEADER_IN_VALUE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
690 switch(ch) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
691 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
692 case HttpTokens.CARRIAGE_RETURN: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
693 case HttpTokens.LINE_FEED: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
694 if (_length > 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
695 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
696 if (_tok1.length() == 0) |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
697 // _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); |
1032 | 698 _tok1 = _buffer.toString(_buffer.markIndex(), _length); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
699 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
700 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
701 // Continuation line! |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
702 if (_multiLineValue == null) _multiLineValue = _tok1; |
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
703 // _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); |
1032 | 704 _tok1 = _buffer.toString(_buffer.markIndex(), _length); |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
705 _multiLineValue += " " + _tok1; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
706 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
707 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
708 _eol=ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
709 _state=STATE_HEADER; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
710 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
711 case HttpTokens.SPACE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
712 case HttpTokens.TAB: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
713 _state=STATE_HEADER_VALUE; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
714 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
715 default: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
716 _length++; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
717 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
718 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
719 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
720 } // end of HEADER states loop |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
721 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
722 // ========================== |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
723 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
724 // Handle HEAD response |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
725 if (_responseStatus>0 && _headResponse) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
726 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
727 _state = _persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
728 _handler.messageComplete(_contentLength); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
729 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
730 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
731 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
732 // ========================== |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
733 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
734 // Handle _content |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
735 length=_buffer.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
736 last=_state; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
737 while (_state > STATE_END && length > 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
738 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
739 if (last!=_state) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
740 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
741 progress++; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
742 last=_state; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
743 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
744 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
745 if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer.peek() == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
746 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
747 _eol=_buffer.get(); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
748 length=_buffer.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
749 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
750 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
751 _eol=0; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
752 switch (_state) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
753 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
754 case STATE_EOF_CONTENT: |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
755 { |
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
756 Buffer chunk = _buffer.get(_buffer.remaining()); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
757 _contentPosition += chunk.remaining(); |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
758 _contentView = chunk; |
1036 | 759 _handler.content(); // May recurse here |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
760 // TODO adjust the _buffer to keep unconsumed content |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
761 return 1; |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
762 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
763 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
764 case STATE_CONTENT: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
765 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
766 long remaining=_contentLength - _contentPosition; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
767 if (remaining == 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
768 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
769 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
770 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
771 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
772 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
773 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
774 if (length > remaining) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
775 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
776 // We can cast reamining to an int as we know that it is smaller than |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
777 // or equal to length which is already an int. |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
778 length=(int)remaining; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
779 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
780 |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
781 Buffer chunk = _buffer.get(length); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
782 _contentPosition += chunk.remaining(); |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
783 _contentView = chunk; |
1036 | 784 _handler.content(); // May recurse here |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
785 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
786 if(_contentPosition == _contentLength) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
787 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
788 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
789 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
790 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
791 // TODO adjust the _buffer to keep unconsumed content |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
792 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
793 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
794 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
795 case STATE_CHUNKED_CONTENT: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
796 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
797 ch=_buffer.peek(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
798 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
799 _eol=_buffer.get(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
800 else if (ch <= HttpTokens.SPACE) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
801 _buffer.get(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
802 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
803 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
804 _chunkLength=0; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
805 _chunkPosition=0; |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
806 _state = STATE_CHUNK_SIZE; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
807 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
808 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
809 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
810 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
811 case STATE_CHUNK_SIZE: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
812 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
813 ch=_buffer.get(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
814 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
815 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
816 _eol=ch; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
817 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
818 if (_chunkLength == 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
819 { |
1037
3c4c7cc7904f
rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
820 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
821 _eol=_buffer.get(); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
822 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
823 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
824 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
825 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
826 else |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
827 _state = STATE_CHUNK; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
828 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
829 else if (ch <= HttpTokens.SPACE || ch == HttpTokens.SEMI_COLON) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
830 _state=STATE_CHUNK_PARAMS; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
831 else if (ch >= '0' && ch <= '9') |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
832 _chunkLength=_chunkLength * 16 + (ch - '0'); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
833 else if (ch >= 'a' && ch <= 'f') |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
834 _chunkLength=_chunkLength * 16 + (10 + ch - 'a'); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
835 else if (ch >= 'A' && ch <= 'F') |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
836 _chunkLength=_chunkLength * 16 + (10 + ch - 'A'); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
837 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
838 throw new IOException("bad chunk char: " + ch); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
839 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
840 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
841 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
842 case STATE_CHUNK_PARAMS: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
843 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
844 ch=_buffer.get(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
845 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
846 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
847 _eol=ch; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
848 if (_chunkLength == 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
849 { |
1037
3c4c7cc7904f
rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
850 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
851 _eol=_buffer.get(); |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
852 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
853 _handler.messageComplete(_contentPosition); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
854 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
855 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
856 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
857 _state=STATE_CHUNK; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
858 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
859 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
860 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
861 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
862 case STATE_CHUNK: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
863 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
864 int remaining=_chunkLength - _chunkPosition; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
865 if (remaining == 0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
866 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
867 _state=STATE_CHUNKED_CONTENT; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
868 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
869 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
870 else if (length > remaining) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
871 length=remaining; |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
872 Buffer chunk = _buffer.get(length); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
873 _contentPosition += chunk.remaining(); |
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
874 _chunkPosition += chunk.remaining(); |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
875 _contentView = chunk; |
1036 | 876 _handler.content(); // May recurse here |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
877 // TODO adjust the _buffer to keep unconsumed content |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
878 return 1; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
879 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
880 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
881 case STATE_SEEKING_EOF: |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
882 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
883 // Close if there is more data than CRLF |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
884 if (_buffer.remaining()>2) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
885 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
886 _state = STATE_END; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
887 _endp.close(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
888 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
889 else |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
890 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
891 // or if the data is not white space |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
892 while (_buffer.remaining()>0) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
893 if (!Character.isWhitespace(_buffer.get())) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
894 { |
1036 | 895 _state = STATE_END; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
896 _endp.close(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
897 _buffer.clear(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
898 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
899 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
900 |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
901 _buffer.clear(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
902 break; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
903 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
904 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
905 |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
906 length=_buffer.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
907 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
908 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
909 return progress; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
910 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
911 catch(HttpException e) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
912 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
913 _persistent = false; |
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1033
diff
changeset
|
914 _state = STATE_SEEKING_EOF; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
915 throw e; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
916 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
917 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
918 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
919 /* ------------------------------------------------------------------------------- */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
920 /** fill the buffers from the endpoint |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
921 * |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
922 */ |
980 | 923 private int fill() throws IOException |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
924 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
925 // Do we have a buffer? |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
926 if (_buffer==null) |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
927 _buffer = _header; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
928 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
929 // Is there unconsumed content in body buffer |
1037
3c4c7cc7904f
rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
930 if (_state>STATE_END && _buffer==_header && !_header.hasRemaining() && _body.hasRemaining()) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
931 { |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
932 _buffer = _body; |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
933 return _buffer.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
934 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
935 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
936 // Shall we switch to a body buffer? |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
937 if (_buffer==_header && _state>STATE_END && _header.remaining()==0 && ((_contentLength-_contentPosition)>_header.capacity())) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
938 { |
1033
4ada7a8c128a
remove HttpParser._buffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1032
diff
changeset
|
939 _buffer = _body; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
940 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
941 |
980 | 942 // Shall we compact the body? |
943 if (_buffer==_body || _state>STATE_END) | |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
944 { |
980 | 945 _buffer.compact(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
946 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
947 |
980 | 948 // Are we full? |
949 if (_buffer.space() == 0) | |
950 { | |
951 LOG.warn("HttpParser Full for {} ",_endp); | |
952 _buffer.clear(); | |
953 throw new HttpException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413, "Request Entity Too Large: "+(_buffer==_body?"body":"head")); | |
954 } | |
1002 | 955 /* why? |
980 | 956 try |
957 { | |
958 int filled = _endp.fill(_buffer); | |
959 return filled; | |
960 } | |
961 catch(IOException e) | |
962 { | |
963 LOG.debug("",e); | |
964 throw (e instanceof EofException) ? e:new EofException(e); | |
965 } | |
1002 | 966 */ |
967 return _endp.fill(_buffer); | |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
968 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
969 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
970 @Override |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
971 public String toString() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
972 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
973 return String.format("%s{s=%d,l=%d,c=%d}", |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
974 getClass().getSimpleName(), |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
975 _state, |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
976 _length, |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
977 _contentLength); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
978 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
979 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
980 public Buffer blockForContent(long maxIdleTime) throws IOException |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
981 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
982 if (_contentView.remaining()>0) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
983 return _contentView; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
984 |
980 | 985 if (_state <= STATE_END || _state==STATE_SEEKING_EOF) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
986 return null; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
987 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
988 try |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
989 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
990 parseNext(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
991 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
992 // parse until some progress is made (or IOException thrown for timeout) |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
993 while(_contentView.remaining() == 0 && !(_state==STATE_END||_state==STATE_SEEKING_EOF) && _endp.isOpen()) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
994 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
995 if (!_endp.isBlocking()) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
996 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
997 if (parseNext()>0) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
998 continue; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
999 |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1000 if (!_endp.blockReadable(maxIdleTime)) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1001 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1002 _endp.close(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1003 throw new EofException("timeout"); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1004 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1005 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1006 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1007 parseNext(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1008 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1009 } |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1010 catch(IOException e) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1011 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1012 // TODO is this needed? |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1013 _endp.close(); |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1014 throw e; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1015 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1016 |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
1017 return _contentView.remaining()>0 ? _contentView : null; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1018 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1019 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1020 /* ------------------------------------------------------------ */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1021 /* (non-Javadoc) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1022 * @see java.io.InputStream#available() |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1023 */ |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1024 public int available() throws IOException |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1025 { |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
1026 if (_contentView.remaining()>0) |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1037
diff
changeset
|
1027 return _contentView.remaining(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1028 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1029 if (_endp.isBlocking()) |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1030 { |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1031 return 0; |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1032 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1033 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1034 parseNext(); |
1041
35e3c864d7a7
make View package local
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
1035 return _contentView.remaining(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1036 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1037 |
980 | 1038 |
1039 public interface EventHandler | |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1040 { |
1036 | 1041 public abstract void content() throws IOException; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1042 |
980 | 1043 public void headerComplete() throws IOException; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1044 |
980 | 1045 public void messageComplete(long contentLength) throws IOException; |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1046 |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1047 /** |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1048 * This is the method called by parser when a HTTP Header name and value is found |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1049 */ |
1021 | 1050 public void parsedHeader(String name, String value) throws IOException; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1051 |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1052 /** |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1053 * This is the method called by parser when the HTTP request line is parsed |
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1054 */ |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
1055 public abstract void startRequest(String method, String url, String version) |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1056 throws IOException; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1057 |
980 | 1058 public void earlyEOF(); |
873
220ad4853cda
remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
1059 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1060 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1061 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1062 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1063 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1064 } |