Mercurial Hosting > luan
changeset 1025:cf0367978d8b
remove View.CaseInsensitive
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 02 Nov 2016 23:46:43 -0600 |
parents | be50ffc0ad5c |
children | 6647dbc8be71 |
files | src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/io/View.java src/org/eclipse/jetty/server/AbstractHttpConnection.java |
diffstat | 3 files changed, 38 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpParser.java Tue Nov 01 03:46:28 2016 -0600 +++ b/src/org/eclipse/jetty/http/HttpParser.java Wed Nov 02 23:46:43 2016 -0600 @@ -67,7 +67,7 @@ private Buffer _buffer; // The current buffer in use (either _header or _content) private String _cached; private String _tok0; // Saved token: header name, request method or response version - private final View.CaseInsensitive _tok1 = new View.CaseInsensitive(); // Saved token: header value, request URI or response code + private String _tok1; // Saved token: header value, request URI or response code private String _multiLineValue; private int _responseStatus; // If >0 then we are parsing a response private boolean _persistent; @@ -324,7 +324,8 @@ case STATE_STATUS: if (ch == HttpTokens.SPACE) { - _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1); +// _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1); + _tok1 = _buffer.peek(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex()).toString(); _state=STATE_SPACE2; continue; } @@ -339,7 +340,8 @@ _state=STATE_HEADER; // _tok0.setPutIndex(_tok0.getIndex()); _tok0 = ""; - _tok1.setPutIndex(_tok1.getIndex()); +// _tok1.setPutIndex(_tok1.getIndex()); + _tok1 = ""; _multiLineValue=null; continue; } @@ -351,14 +353,15 @@ case STATE_URI: if (ch == HttpTokens.SPACE) { - _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1); +// _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1); + _tok1 = _buffer.peek(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex()).toString(); _state=STATE_SPACE2; continue; } else if (ch < HttpTokens.SPACE && ch>=0) { // HTTP/0.9 - _handler.startRequest(_tok0, _buffer.sliceFromMark(), null); + _handler.startRequest(_tok0, _buffer.sliceFromMark().toString(), null); _persistent=false; _state=STATE_SEEKING_EOF; _handler.headerComplete(); @@ -381,7 +384,8 @@ _state=STATE_HEADER; // _tok0.setPutIndex(_tok0.getIndex()); _tok0 = ""; - _tok1.setPutIndex(_tok1.getIndex()); +// _tok1.setPutIndex(_tok1.getIndex()); + _tok1 = ""; _multiLineValue=null; } else @@ -411,7 +415,8 @@ _state=STATE_HEADER; // _tok0.setPutIndex(_tok0.getIndex()); _tok0 = ""; - _tok1.setPutIndex(_tok1.getIndex()); +// _tok1.setPutIndex(_tok1.getIndex()); + _tok1 = ""; _multiLineValue=null; continue; } @@ -437,7 +442,7 @@ { String header = _cached!=null ? _cached : _tok0; _cached = null; - String value = _multiLineValue == null ? _tok1.toString() : _multiLineValue; + String value = _multiLineValue == null ? _tok1 : _multiLineValue; int ho = HttpHeaders.CACHE.getOrdinal(header); if (ho >= 0) @@ -513,7 +518,8 @@ _handler.parsedHeader(header, value); // _tok0.setPutIndex(_tok0.getIndex()); _tok0 = ""; - _tok1.setPutIndex(_tok1.getIndex()); +// _tok1.setPutIndex(_tok1.getIndex()); + _tok1 = ""; _multiLineValue=null; } _buffer.setMarkIndex(-1); @@ -680,13 +686,15 @@ if (_length > 0) { if (_tok1.length() == 0) - _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); +// _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); + _tok1 = _buffer.peek(_buffer.markIndex(), _length).toString(); else { // Continuation line! - if (_multiLineValue == null) _multiLineValue=_tok1.toString(StringUtil.__ISO_8859_1); - _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); - _multiLineValue += " " + _tok1.toString(StringUtil.__ISO_8859_1); + if (_multiLineValue == null) _multiLineValue = _tok1; +// _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); + _tok1 = _buffer.peek(_buffer.markIndex(), _length).toString(); + _multiLineValue += " " + _tok1; } } _eol=ch; @@ -713,13 +721,15 @@ if (_length > 0) { if (_tok1.length() == 0) - _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); +// _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); + _tok1 = _buffer.peek(_buffer.markIndex(), _length).toString(); else { // Continuation line! - if (_multiLineValue == null) _multiLineValue=_tok1.toString(StringUtil.__ISO_8859_1); - _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); - _multiLineValue += " " + _tok1.toString(StringUtil.__ISO_8859_1); + if (_multiLineValue == null) _multiLineValue = _tok1; +// _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length); + _tok1 = _buffer.peek(_buffer.markIndex(), _length).toString(); + _multiLineValue += " " + _tok1; } } _eol=ch; @@ -1067,7 +1077,8 @@ // _tok0.update(_header); _tok0 = ""; //System.out.println("qqqqqqqqqqqqqqqq l "+_tok0); - _tok1.update(_header); +// _tok1.update(_header); + _tok1 = ""; } return _header; } @@ -1147,7 +1158,7 @@ /** * This is the method called by parser when the HTTP request line is parsed */ - public abstract void startRequest(String method, Buffer url, String version) + public abstract void startRequest(String method, String url, String version) throws IOException; public void earlyEOF();
--- a/src/org/eclipse/jetty/io/View.java Tue Nov 01 03:46:28 2016 -0600 +++ b/src/org/eclipse/jetty/io/View.java Wed Nov 02 23:46:43 2016 -0600 @@ -25,9 +25,9 @@ * * */ -public class View extends AbstractBuffer +public final class View extends AbstractBuffer { - Buffer _buffer; + private Buffer _buffer; /** * @param buffer The <code>Buffer</code> on which we are presenting a <code>View</code>. @@ -224,28 +224,4 @@ return "INVALID"; return super.toString(); } - - public static class CaseInsensitive extends View implements Buffer.CaseInsensitve - { - public CaseInsensitive() - { - super(); - } - - public CaseInsensitive(Buffer buffer, int mark, int get, int put, int access) - { - super(buffer,mark,get,put,access); - } - - public CaseInsensitive(Buffer buffer) - { - super(buffer); - } - - @Override - public boolean equals(Object obj) - { - return this==obj ||((obj instanceof Buffer)&&((Buffer)obj).equalsIgnoreCase(this)) || super.equals(obj); - } - } }
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java Tue Nov 01 03:46:28 2016 -0600 +++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java Wed Nov 02 23:46:43 2016 -0600 @@ -445,10 +445,8 @@ _parser); } - private void startRequest(String method, Buffer uri, String version) throws IOException + private void startRequest(String method, String uri, String version) throws IOException { - uri=uri.asImmutableBuffer(); - _host = false; _expect = false; _expect100Continue = false; @@ -462,19 +460,20 @@ try { _head = false; + byte[] bytes = StringUtil.getBytes(uri); switch (HttpMethods.CACHE.getOrdinal(method)) { case HttpMethods.CONNECT_ORDINAL: - _uri.parseConnect(uri.array(), uri.getIndex(), uri.length()); + _uri.parseConnect(bytes, 0, bytes.length); break; case HttpMethods.HEAD_ORDINAL: _head = true; - _uri.parse(uri.array(), uri.getIndex(), uri.length()); + _uri.parse(bytes, 0, bytes.length); break; default: - _uri.parse(uri.array(), uri.getIndex(), uri.length()); + _uri.parse(bytes, 0, bytes.length); } _request.setUri(_uri); @@ -657,7 +656,7 @@ private class RequestHandler implements HttpParser.EventHandler { @Override - public void startRequest(String method, Buffer uri, String version) throws IOException + public void startRequest(String method, String uri, String version) throws IOException { AbstractHttpConnection.this.startRequest(method, uri, version); }