Mercurial Hosting > luan
changeset 1018:4dc1e1a18661
remove HttpSchemes
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 24 Oct 2016 05:37:24 -0600 |
parents | d2c3ff33387c |
children | f126d30e04a4 |
files | src/org/eclipse/jetty/http/HttpSchemes.java src/org/eclipse/jetty/http/HttpURI.java src/org/eclipse/jetty/io/BufferUtil.java src/org/eclipse/jetty/io/ByteArrayBuffer.java src/org/eclipse/jetty/server/Response.java src/org/eclipse/jetty/server/ssl/SslCertificates.java src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java |
diffstat | 7 files changed, 908 insertions(+), 1011 deletions(-) [+] |
line wrap: on
line diff
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/http/HttpSchemes.java --- a/src/org/eclipse/jetty/http/HttpSchemes.java Mon Oct 24 01:56:08 2016 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.http; - -import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.ByteArrayBuffer; - -/* ------------------------------------------------------------------------------- */ -/** - * - * - */ -public class HttpSchemes -{ - public final static String - HTTP ="http", - HTTPS="https"; - - public final static Buffer - HTTP_BUFFER = new ByteArrayBuffer(HTTP), - HTTPS_BUFFER = new ByteArrayBuffer(HTTPS); -}
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/http/HttpURI.java --- a/src/org/eclipse/jetty/http/HttpURI.java Mon Oct 24 01:56:08 2016 -0600 +++ b/src/org/eclipse/jetty/http/HttpURI.java Mon Oct 24 05:37:24 2016 -0600 @@ -47,725 +47,725 @@ */ public class HttpURI { - private static final byte[] __empty={}; - private final static int - START=0, - AUTH_OR_PATH=1, - SCHEME_OR_PATH=2, - AUTH=4, - IPV6=5, - PORT=6, - PATH=7, - PARAM=8, - QUERY=9, - ASTERISK=10; + private static final byte[] __empty={}; + private final static int + START=0, + AUTH_OR_PATH=1, + SCHEME_OR_PATH=2, + AUTH=4, + IPV6=5, + PORT=6, + PATH=7, + PARAM=8, + QUERY=9, + ASTERISK=10; - boolean _partial=false; - byte[] _raw=__empty; - String _rawString; - int _scheme; - int _authority; - int _host; - int _port; - int _portValue; - int _path; - int _param; - int _query; - int _fragment; - int _end; - boolean _encoded=false; + boolean _partial=false; + byte[] _raw=__empty; + String _rawString; + int _scheme; + int _authority; + int _host; + int _port; + int _portValue; + int _path; + int _param; + int _query; + int _fragment; + int _end; + boolean _encoded=false; - final Utf8StringBuilder _utf8b = new Utf8StringBuilder(64); + final Utf8StringBuilder _utf8b = new Utf8StringBuilder(64); - public HttpURI() - { + public HttpURI() + { - } + } - /* ------------------------------------------------------------ */ - /** - * @param parsePartialAuth If True, parse auth without prior scheme, else treat all URIs starting with / as paths - */ - public HttpURI(boolean parsePartialAuth) - { - _partial=parsePartialAuth; - } + /* ------------------------------------------------------------ */ + /** + * @param parsePartialAuth If True, parse auth without prior scheme, else treat all URIs starting with / as paths + */ + public HttpURI(boolean parsePartialAuth) + { + _partial=parsePartialAuth; + } - public HttpURI(String raw) - { - _rawString=raw; - byte[] b; - try - { - b = raw.getBytes(StringUtil.__UTF8); - } - catch (UnsupportedEncodingException e) - { - throw new RuntimeException(e.getMessage()); - } - parse(b,0,b.length); - } + public HttpURI(String raw) + { + _rawString=raw; + byte[] b; + try + { + b = raw.getBytes(StringUtil.__UTF8); + } + catch (UnsupportedEncodingException e) + { + throw new RuntimeException(e.getMessage()); + } + parse(b,0,b.length); + } - public HttpURI(byte[] raw,int offset, int length) - { - parse2(raw,offset,length); - } - - public HttpURI(URI uri) - { - parse(uri.toASCIIString()); - } + public HttpURI(byte[] raw,int offset, int length) + { + parse2(raw,offset,length); + } + + public HttpURI(URI uri) + { + parse(uri.toASCIIString()); + } - public void parse(String raw) - { - byte[] b = raw.getBytes(); - parse2(b,0,b.length); - _rawString=raw; - } + public void parse(String raw) + { + byte[] b = raw.getBytes(); + parse2(b,0,b.length); + _rawString=raw; + } - public void parse(byte[] raw,int offset, int length) - { - _rawString=null; - parse2(raw,offset,length); - } + public void parse(byte[] raw,int offset, int length) + { + _rawString=null; + parse2(raw,offset,length); + } - public void parseConnect(byte[] raw,int offset, int length) - { - _rawString=null; - _encoded=false; - _raw=raw; - int i=offset; - int e=offset+length; - int state=AUTH; - _end=offset+length; - _scheme=offset; - _authority=offset; - _host=offset; - _port=_end; - _portValue=-1; - _path=_end; - _param=_end; - _query=_end; - _fragment=_end; + public void parseConnect(byte[] raw,int offset, int length) + { + _rawString=null; + _encoded=false; + _raw=raw; + int i=offset; + int e=offset+length; + int state=AUTH; + _end=offset+length; + _scheme=offset; + _authority=offset; + _host=offset; + _port=_end; + _portValue=-1; + _path=_end; + _param=_end; + _query=_end; + _fragment=_end; - loop: while (i<e) - { - char c=(char)(0xff&_raw[i]); - int s=i++; + loop: while (i<e) + { + char c=(char)(0xff&_raw[i]); + int s=i++; - switch (state) - { - case AUTH: - { - switch (c) - { - case ':': - { - _port = s; - break loop; - } - case '[': - { - state = IPV6; - break; - } - } - continue; - } + switch (state) + { + case AUTH: + { + switch (c) + { + case ':': + { + _port = s; + break loop; + } + case '[': + { + state = IPV6; + break; + } + } + continue; + } - case IPV6: - { - switch (c) - { - case '/': - { - throw new IllegalArgumentException("No closing ']' for " + StringUtil.toString(_raw,offset,length,URIUtil.__CHARSET)); - } - case ']': - { - state = AUTH; - break; - } - } + case IPV6: + { + switch (c) + { + case '/': + { + throw new IllegalArgumentException("No closing ']' for " + StringUtil.toString(_raw,offset,length,URIUtil.__CHARSET)); + } + case ']': + { + state = AUTH; + break; + } + } - continue; - } - } - } + continue; + } + } + } - if (_port<_path) - _portValue=TypeUtil.parseInt(_raw, _port+1, _path-_port-1,10); - else - throw new IllegalArgumentException("No port"); - _path=offset; - } + if (_port<_path) + _portValue=TypeUtil.parseInt(_raw, _port+1, _path-_port-1,10); + else + throw new IllegalArgumentException("No port"); + _path=offset; + } - private void parse2(byte[] raw,int offset, int length) - { - _encoded=false; - _raw=raw; - int i=offset; - int e=offset+length; - int state=START; - int m=offset; - _end=offset+length; - _scheme=offset; - _authority=offset; - _host=offset; - _port=offset; - _portValue=-1; - _path=offset; - _param=_end; - _query=_end; - _fragment=_end; - while (i<e) - { - char c=(char)(0xff&_raw[i]); - int s=i++; + private void parse2(byte[] raw,int offset, int length) + { + _encoded=false; + _raw=raw; + int i=offset; + int e=offset+length; + int state=START; + int m=offset; + _end=offset+length; + _scheme=offset; + _authority=offset; + _host=offset; + _port=offset; + _portValue=-1; + _path=offset; + _param=_end; + _query=_end; + _fragment=_end; + while (i<e) + { + char c=(char)(0xff&_raw[i]); + int s=i++; - state: switch (state) - { - case START: - { - m=s; - switch(c) - { - case '/': - state=AUTH_OR_PATH; - break; - case ';': - _param=s; - state=PARAM; - break; - case '?': - _param=s; - _query=s; - state=QUERY; - break; - case '#': - _param=s; - _query=s; - _fragment=s; - break; - case '*': - _path=s; - state=ASTERISK; - break; + state: switch (state) + { + case START: + { + m=s; + switch(c) + { + case '/': + state=AUTH_OR_PATH; + break; + case ';': + _param=s; + state=PARAM; + break; + case '?': + _param=s; + _query=s; + state=QUERY; + break; + case '#': + _param=s; + _query=s; + _fragment=s; + break; + case '*': + _path=s; + state=ASTERISK; + break; - default: - state=SCHEME_OR_PATH; - } + default: + state=SCHEME_OR_PATH; + } - continue; - } + continue; + } - case AUTH_OR_PATH: - { - if ((_partial||_scheme!=_authority) && c=='/') - { - _host=i; - _port=_end; - _path=_end; - state=AUTH; - } - else if (c==';' || c=='?' || c=='#') - { - i--; - state=PATH; - } - else - { - _host=m; - _port=m; - state=PATH; - } - continue; - } + case AUTH_OR_PATH: + { + if ((_partial||_scheme!=_authority) && c=='/') + { + _host=i; + _port=_end; + _path=_end; + state=AUTH; + } + else if (c==';' || c=='?' || c=='#') + { + i--; + state=PATH; + } + else + { + _host=m; + _port=m; + state=PATH; + } + continue; + } - case SCHEME_OR_PATH: - { - // short cut for http and https - if (length>6 && c=='t') - { - if (_raw[offset+3]==':') - { - s=offset+3; - i=offset+4; - c=':'; - } - else if (_raw[offset+4]==':') - { - s=offset+4; - i=offset+5; - c=':'; - } - else if (_raw[offset+5]==':') - { - s=offset+5; - i=offset+6; - c=':'; - } - } + case SCHEME_OR_PATH: + { + // short cut for http and https + if (length>6 && c=='t') + { + if (_raw[offset+3]==':') + { + s=offset+3; + i=offset+4; + c=':'; + } + else if (_raw[offset+4]==':') + { + s=offset+4; + i=offset+5; + c=':'; + } + else if (_raw[offset+5]==':') + { + s=offset+5; + i=offset+6; + c=':'; + } + } - switch (c) - { - case ':': - { - m = i++; - _authority = m; - _path = m; - c = (char)(0xff & _raw[i]); - if (c == '/') - state = AUTH_OR_PATH; - else - { - _host = m; - _port = m; - state = PATH; - } - break; - } + switch (c) + { + case ':': + { + m = i++; + _authority = m; + _path = m; + c = (char)(0xff & _raw[i]); + if (c == '/') + state = AUTH_OR_PATH; + else + { + _host = m; + _port = m; + state = PATH; + } + break; + } - case '/': - { - state = PATH; - break; - } + case '/': + { + state = PATH; + break; + } - case ';': - { - _param = s; - state = PARAM; - break; - } + case ';': + { + _param = s; + state = PARAM; + break; + } - case '?': - { - _param = s; - _query = s; - state = QUERY; - break; - } + case '?': + { + _param = s; + _query = s; + state = QUERY; + break; + } - case '#': - { - _param = s; - _query = s; - _fragment = s; - break; - } - } - continue; - } + case '#': + { + _param = s; + _query = s; + _fragment = s; + break; + } + } + continue; + } - case AUTH: - { - switch (c) - { + case AUTH: + { + switch (c) + { - case '/': - { - m = s; - _path = m; - _port = _path; - state = PATH; - break; - } - case '@': - { - _host = i; - break; - } - case ':': - { - _port = s; - state = PORT; - break; - } - case '[': - { - state = IPV6; - break; - } - } - continue; - } + case '/': + { + m = s; + _path = m; + _port = _path; + state = PATH; + break; + } + case '@': + { + _host = i; + break; + } + case ':': + { + _port = s; + state = PORT; + break; + } + case '[': + { + state = IPV6; + break; + } + } + continue; + } - case IPV6: - { - switch (c) - { - case '/': - { - throw new IllegalArgumentException("No closing ']' for " + StringUtil.toString(_raw,offset,length,URIUtil.__CHARSET)); - } - case ']': - { - state = AUTH; - break; - } - } + case IPV6: + { + switch (c) + { + case '/': + { + throw new IllegalArgumentException("No closing ']' for " + StringUtil.toString(_raw,offset,length,URIUtil.__CHARSET)); + } + case ']': + { + state = AUTH; + break; + } + } - continue; - } + continue; + } - case PORT: - { - if (c=='/') - { - m=s; - _path=m; - if (_port<=_authority) - _port=_path; - state=PATH; - } - continue; - } + case PORT: + { + if (c=='/') + { + m=s; + _path=m; + if (_port<=_authority) + _port=_path; + state=PATH; + } + continue; + } - case PATH: - { - switch (c) - { - case ';': - { - _param = s; - state = PARAM; - break; - } - case '?': - { - _param = s; - _query = s; - state = QUERY; - break; - } - case '#': - { - _param = s; - _query = s; - _fragment = s; - break state; - } - case '%': - { - _encoded=true; - } - } - continue; - } + case PATH: + { + switch (c) + { + case ';': + { + _param = s; + state = PARAM; + break; + } + case '?': + { + _param = s; + _query = s; + state = QUERY; + break; + } + case '#': + { + _param = s; + _query = s; + _fragment = s; + break state; + } + case '%': + { + _encoded=true; + } + } + continue; + } - case PARAM: - { - switch (c) - { - case '?': - { - _query = s; - state = QUERY; - break; - } - case '#': - { - _query = s; - _fragment = s; - break state; - } - } - continue; - } + case PARAM: + { + switch (c) + { + case '?': + { + _query = s; + state = QUERY; + break; + } + case '#': + { + _query = s; + _fragment = s; + break state; + } + } + continue; + } - case QUERY: - { - if (c=='#') - { - _fragment=s; - break state; - } - continue; - } + case QUERY: + { + if (c=='#') + { + _fragment=s; + break state; + } + continue; + } - case ASTERISK: - { - throw new IllegalArgumentException("only '*'"); - } - } - } + case ASTERISK: + { + throw new IllegalArgumentException("only '*'"); + } + } + } - if (_port<_path) - _portValue=TypeUtil.parseInt(_raw, _port+1, _path-_port-1,10); - } + if (_port<_path) + _portValue=TypeUtil.parseInt(_raw, _port+1, _path-_port-1,10); + } - private String toUtf8String(int offset,int length) - { - _utf8b.reset(); - _utf8b.append(_raw,offset,length); - return _utf8b.toString(); - } + private String toUtf8String(int offset,int length) + { + _utf8b.reset(); + _utf8b.append(_raw,offset,length); + return _utf8b.toString(); + } - public String getScheme() - { - if (_scheme==_authority) - return null; - int l=_authority-_scheme; - if (l==5 && - _raw[_scheme]=='h' && - _raw[_scheme+1]=='t' && - _raw[_scheme+2]=='t' && - _raw[_scheme+3]=='p' ) - return HttpSchemes.HTTP; - if (l==6 && - _raw[_scheme]=='h' && - _raw[_scheme+1]=='t' && - _raw[_scheme+2]=='t' && - _raw[_scheme+3]=='p' && - _raw[_scheme+4]=='s' ) - return HttpSchemes.HTTPS; + public String getScheme() + { + if (_scheme==_authority) + return null; + int l=_authority-_scheme; + if (l==5 && + _raw[_scheme]=='h' && + _raw[_scheme+1]=='t' && + _raw[_scheme+2]=='t' && + _raw[_scheme+3]=='p' ) + return "http"; + if (l==6 && + _raw[_scheme]=='h' && + _raw[_scheme+1]=='t' && + _raw[_scheme+2]=='t' && + _raw[_scheme+3]=='p' && + _raw[_scheme+4]=='s' ) + return "https"; - return toUtf8String(_scheme,_authority-_scheme-1); - } + return toUtf8String(_scheme,_authority-_scheme-1); + } - public String getAuthority() - { - if (_authority==_path) - return null; - return toUtf8String(_authority,_path-_authority); - } + public String getAuthority() + { + if (_authority==_path) + return null; + return toUtf8String(_authority,_path-_authority); + } - public String getHost() - { - if (_host==_port) - return null; - return toUtf8String(_host,_port-_host); - } + public String getHost() + { + if (_host==_port) + return null; + return toUtf8String(_host,_port-_host); + } - public int getPort() - { - return _portValue; - } + public int getPort() + { + return _portValue; + } - public String getPath() - { - if (_path==_param) - return null; - return toUtf8String(_path,_param-_path); - } + public String getPath() + { + if (_path==_param) + return null; + return toUtf8String(_path,_param-_path); + } - public String getDecodedPath() - { - if (_path==_param) - return null; + public String getDecodedPath() + { + if (_path==_param) + return null; - int length = _param-_path; - boolean decoding=false; + int length = _param-_path; + boolean decoding=false; - for (int i=_path;i<_param;i++) - { - byte b = _raw[i]; + for (int i=_path;i<_param;i++) + { + byte b = _raw[i]; - if (b=='%') - { - if (!decoding) - { - _utf8b.reset(); - _utf8b.append(_raw,_path,i-_path); - decoding=true; - } - - if ((i+2)>=_param) - throw new IllegalArgumentException("Bad % encoding: "+this); - if (_raw[i+1]=='u') - { - if ((i+5)>=_param) - throw new IllegalArgumentException("Bad %u encoding: "+this); - try - { - String unicode = new String(Character.toChars(TypeUtil.parseInt(_raw,i+2,4,16))); - _utf8b.getStringBuilder().append(unicode); - i+=5; - } - catch(Exception e) - { - throw new RuntimeException(e); - } - } - else - { - b=(byte)(0xff&TypeUtil.parseInt(_raw,i+1,2,16)); - _utf8b.append(b); - i+=2; - } - continue; - } - else if (decoding) - { - _utf8b.append(b); - } - } + if (b=='%') + { + if (!decoding) + { + _utf8b.reset(); + _utf8b.append(_raw,_path,i-_path); + decoding=true; + } + + if ((i+2)>=_param) + throw new IllegalArgumentException("Bad % encoding: "+this); + if (_raw[i+1]=='u') + { + if ((i+5)>=_param) + throw new IllegalArgumentException("Bad %u encoding: "+this); + try + { + String unicode = new String(Character.toChars(TypeUtil.parseInt(_raw,i+2,4,16))); + _utf8b.getStringBuilder().append(unicode); + i+=5; + } + catch(Exception e) + { + throw new RuntimeException(e); + } + } + else + { + b=(byte)(0xff&TypeUtil.parseInt(_raw,i+1,2,16)); + _utf8b.append(b); + i+=2; + } + continue; + } + else if (decoding) + { + _utf8b.append(b); + } + } - if (!decoding) - return toUtf8String(_path,length); - return _utf8b.toString(); - } - - public String getDecodedPath(String encoding) - { - if (_path==_param) - return null; + if (!decoding) + return toUtf8String(_path,length); + return _utf8b.toString(); + } + + public String getDecodedPath(String encoding) + { + if (_path==_param) + return null; - int length = _param-_path; - byte[] bytes=null; - int n=0; + int length = _param-_path; + byte[] bytes=null; + int n=0; - for (int i=_path;i<_param;i++) - { - byte b = _raw[i]; + for (int i=_path;i<_param;i++) + { + byte b = _raw[i]; - if (b=='%') - { - if (bytes==null) - { - bytes=new byte[length]; - System.arraycopy(_raw,_path,bytes,0,n); - } - - if ((i+2)>=_param) - throw new IllegalArgumentException("Bad % encoding: "+this); - if (_raw[i+1]=='u') - { - if ((i+5)>=_param) - throw new IllegalArgumentException("Bad %u encoding: "+this); + if (b=='%') + { + if (bytes==null) + { + bytes=new byte[length]; + System.arraycopy(_raw,_path,bytes,0,n); + } + + if ((i+2)>=_param) + throw new IllegalArgumentException("Bad % encoding: "+this); + if (_raw[i+1]=='u') + { + if ((i+5)>=_param) + throw new IllegalArgumentException("Bad %u encoding: "+this); - try - { - String unicode = new String(Character.toChars(TypeUtil.parseInt(_raw,i+2,4,16))); - byte[] encoded = unicode.getBytes(encoding); - System.arraycopy(encoded,0,bytes,n,encoded.length); - n+=encoded.length; - i+=5; - } - catch(Exception e) - { - throw new RuntimeException(e); - } - } - else - { - b=(byte)(0xff&TypeUtil.parseInt(_raw,i+1,2,16)); - bytes[n++]=b; - i+=2; - } - continue; - } - else if (bytes==null) - { - n++; - continue; - } + try + { + String unicode = new String(Character.toChars(TypeUtil.parseInt(_raw,i+2,4,16))); + byte[] encoded = unicode.getBytes(encoding); + System.arraycopy(encoded,0,bytes,n,encoded.length); + n+=encoded.length; + i+=5; + } + catch(Exception e) + { + throw new RuntimeException(e); + } + } + else + { + b=(byte)(0xff&TypeUtil.parseInt(_raw,i+1,2,16)); + bytes[n++]=b; + i+=2; + } + continue; + } + else if (bytes==null) + { + n++; + continue; + } - bytes[n++]=b; - } + bytes[n++]=b; + } - if (bytes==null) - return StringUtil.toString(_raw,_path,_param-_path,encoding); + if (bytes==null) + return StringUtil.toString(_raw,_path,_param-_path,encoding); - return StringUtil.toString(bytes,0,n,encoding); - } - - - - - + return StringUtil.toString(bytes,0,n,encoding); + } + + + + + - public String getPathAndParam() - { - if (_path==_query) - return null; - return toUtf8String(_path,_query-_path); - } + public String getPathAndParam() + { + if (_path==_query) + return null; + return toUtf8String(_path,_query-_path); + } - public String getCompletePath() - { - if (_path==_end) - return null; - return toUtf8String(_path,_end-_path); - } + public String getCompletePath() + { + if (_path==_end) + return null; + return toUtf8String(_path,_end-_path); + } - public String getParam() - { - if (_param==_query) - return null; - return toUtf8String(_param+1,_query-_param-1); - } + public String getParam() + { + if (_param==_query) + return null; + return toUtf8String(_param+1,_query-_param-1); + } - public String getQuery() - { - if (_query==_fragment) - return null; - return toUtf8String(_query+1,_fragment-_query-1); - } + public String getQuery() + { + if (_query==_fragment) + return null; + return toUtf8String(_query+1,_fragment-_query-1); + } - public String getQuery(String encoding) - { - if (_query==_fragment) - return null; - return StringUtil.toString(_raw,_query+1,_fragment-_query-1,encoding); - } + public String getQuery(String encoding) + { + if (_query==_fragment) + return null; + return StringUtil.toString(_raw,_query+1,_fragment-_query-1,encoding); + } - public boolean hasQuery() - { - return (_fragment>_query); - } + public boolean hasQuery() + { + return (_fragment>_query); + } - public String getFragment() - { - if (_fragment==_end) - return null; - return toUtf8String(_fragment+1,_end-_fragment-1); - } + public String getFragment() + { + if (_fragment==_end) + return null; + return toUtf8String(_fragment+1,_end-_fragment-1); + } - public void decodeQueryTo(MultiMap parameters) - { - if (_query==_fragment) - return; - _utf8b.reset(); - UrlEncoded.decodeUtf8To(_raw,_query+1,_fragment-_query-1,parameters,_utf8b); - } + public void decodeQueryTo(MultiMap parameters) + { + if (_query==_fragment) + return; + _utf8b.reset(); + UrlEncoded.decodeUtf8To(_raw,_query+1,_fragment-_query-1,parameters,_utf8b); + } - public void decodeQueryTo(MultiMap parameters, String encoding) - throws UnsupportedEncodingException - { - if (_query==_fragment) - return; + public void decodeQueryTo(MultiMap parameters, String encoding) + throws UnsupportedEncodingException + { + if (_query==_fragment) + return; - if (encoding==null || StringUtil.isUTF8(encoding)) - UrlEncoded.decodeUtf8To(_raw,_query+1,_fragment-_query-1,parameters); - else - UrlEncoded.decodeTo(StringUtil.toString(_raw,_query+1,_fragment-_query-1,encoding),parameters,encoding); - } + if (encoding==null || StringUtil.isUTF8(encoding)) + UrlEncoded.decodeUtf8To(_raw,_query+1,_fragment-_query-1,parameters); + else + UrlEncoded.decodeTo(StringUtil.toString(_raw,_query+1,_fragment-_query-1,encoding),parameters,encoding); + } - public void clear() - { - _scheme=_authority=_host=_port=_path=_param=_query=_fragment=_end=0; - _raw=__empty; - _rawString=""; - _encoded=false; - } + public void clear() + { + _scheme=_authority=_host=_port=_path=_param=_query=_fragment=_end=0; + _raw=__empty; + _rawString=""; + _encoded=false; + } - @Override - public String toString() - { - if (_rawString==null) - _rawString=toUtf8String(_scheme,_end-_scheme); - return _rawString; - } + @Override + public String toString() + { + if (_rawString==null) + _rawString=toUtf8String(_scheme,_end-_scheme); + return _rawString; + } - public void writeTo(Utf8StringBuilder buf) - { - buf.append(_raw,_scheme,_end-_scheme); - } + public void writeTo(Utf8StringBuilder buf) + { + buf.append(_raw,_scheme,_end-_scheme); + } }
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/io/BufferUtil.java --- a/src/org/eclipse/jetty/io/BufferUtil.java Mon Oct 24 01:56:08 2016 -0600 +++ b/src/org/eclipse/jetty/io/BufferUtil.java Mon Oct 24 05:37:24 2016 -0600 @@ -26,334 +26,279 @@ * * */ -public class BufferUtil +public final class BufferUtil { - static final byte SPACE= 0x20; - static final byte MINUS= '-'; - static final byte[] DIGIT= - {(byte)'0',(byte)'1',(byte)'2',(byte)'3',(byte)'4',(byte)'5',(byte)'6',(byte)'7',(byte)'8',(byte)'9',(byte)'A',(byte)'B',(byte)'C',(byte)'D',(byte)'E',(byte)'F'}; + static final byte SPACE= 0x20; + static final byte MINUS= '-'; + static final byte[] DIGIT= + {(byte)'0',(byte)'1',(byte)'2',(byte)'3',(byte)'4',(byte)'5',(byte)'6',(byte)'7',(byte)'8',(byte)'9',(byte)'A',(byte)'B',(byte)'C',(byte)'D',(byte)'E',(byte)'F'}; - /** - * Convert buffer to an integer. - * Parses up to the first non-numeric character. If no number is found an - * IllegalArgumentException is thrown - * @param buffer A buffer containing an integer. The position is not changed. - * @return an int - */ - public static int toInt(Buffer buffer) - { - int val= 0; - boolean started= false; - boolean minus= false; - for (int i= buffer.getIndex(); i < buffer.putIndex(); i++) - { - byte b= buffer.peek(i); - if (b <= SPACE) - { - if (started) - break; - } - else if (b >= '0' && b <= '9') - { - val= val * 10 + (b - '0'); - started= true; - } - else if (b == MINUS && !started) - { - minus= true; - } - else - break; - } + /** + * Convert buffer to an integer. + * Parses up to the first non-numeric character. If no number is found an + * IllegalArgumentException is thrown + * @param buffer A buffer containing an integer. The position is not changed. + * @return an int + */ + public static int toInt(Buffer buffer) + { + int val= 0; + boolean started= false; + boolean minus= false; + for (int i= buffer.getIndex(); i < buffer.putIndex(); i++) + { + byte b= buffer.peek(i); + if (b <= SPACE) + { + if (started) + break; + } + else if (b >= '0' && b <= '9') + { + val= val * 10 + (b - '0'); + started= true; + } + else if (b == MINUS && !started) + { + minus= true; + } + else + break; + } - if (started) - return minus ? (-val) : val; - throw new NumberFormatException(buffer.toString()); - } - - /** - * Convert buffer to an long. - * Parses up to the first non-numeric character. If no number is found an - * IllegalArgumentException is thrown - * @param buffer A buffer containing an integer. The position is not changed. - * @return an int - */ - public static long toLong(Buffer buffer) - { - long val= 0; - boolean started= false; - boolean minus= false; - for (int i= buffer.getIndex(); i < buffer.putIndex(); i++) - { - byte b= buffer.peek(i); - if (b <= SPACE) - { - if (started) - break; - } - else if (b >= '0' && b <= '9') - { - val= val * 10L + (b - '0'); - started= true; - } - else if (b == MINUS && !started) - { - minus= true; - } - else - break; - } - - if (started) - return minus ? (-val) : val; - throw new NumberFormatException(buffer.toString()); - } + if (started) + return minus ? (-val) : val; + throw new NumberFormatException(buffer.toString()); + } + + /** + * Convert buffer to an long. + * Parses up to the first non-numeric character. If no number is found an + * IllegalArgumentException is thrown + * @param buffer A buffer containing an integer. The position is not changed. + * @return an int + */ + public static long toLong(Buffer buffer) + { + long val= 0; + boolean started= false; + boolean minus= false; + for (int i= buffer.getIndex(); i < buffer.putIndex(); i++) + { + byte b= buffer.peek(i); + if (b <= SPACE) + { + if (started) + break; + } + else if (b >= '0' && b <= '9') + { + val= val * 10L + (b - '0'); + started= true; + } + else if (b == MINUS && !started) + { + minus= true; + } + else + break; + } - public static void putHexInt(Buffer buffer, int n) - { - - if (n < 0) - { - buffer.put((byte)'-'); + if (started) + return minus ? (-val) : val; + throw new NumberFormatException(buffer.toString()); + } - if (n == Integer.MIN_VALUE) - { - buffer.put((byte)(0x7f&'8')); - buffer.put((byte)(0x7f&'0')); - buffer.put((byte)(0x7f&'0')); - buffer.put((byte)(0x7f&'0')); - buffer.put((byte)(0x7f&'0')); - buffer.put((byte)(0x7f&'0')); - buffer.put((byte)(0x7f&'0')); - buffer.put((byte)(0x7f&'0')); - - return; - } - n= -n; - } + public static void putHexInt(Buffer buffer, int n) + { + + if (n < 0) + { + buffer.put((byte)'-'); - if (n < 0x10) - { - buffer.put(DIGIT[n]); - } - else - { - boolean started= false; - // This assumes constant time int arithmatic - for (int i= 0; i < hexDivisors.length; i++) - { - if (n < hexDivisors[i]) - { - if (started) - buffer.put((byte)'0'); - continue; - } + if (n == Integer.MIN_VALUE) + { + buffer.put((byte)(0x7f&'8')); + buffer.put((byte)(0x7f&'0')); + buffer.put((byte)(0x7f&'0')); + buffer.put((byte)(0x7f&'0')); + buffer.put((byte)(0x7f&'0')); + buffer.put((byte)(0x7f&'0')); + buffer.put((byte)(0x7f&'0')); + buffer.put((byte)(0x7f&'0')); + + return; + } + n= -n; + } - started= true; - int d= n / hexDivisors[i]; - buffer.put(DIGIT[d]); - n= n - d * hexDivisors[i]; - } - } - } + if (n < 0x10) + { + buffer.put(DIGIT[n]); + } + else + { + boolean started= false; + // This assumes constant time int arithmatic + for (int i= 0; i < hexDivisors.length; i++) + { + if (n < hexDivisors[i]) + { + if (started) + buffer.put((byte)'0'); + continue; + } - /* ------------------------------------------------------------ */ - /** - * Add hex integer BEFORE current getIndex. - * @param buffer - * @param n - */ - public static void prependHexInt(Buffer buffer, int n) - { - if (n==0) - { - int gi=buffer.getIndex(); - buffer.poke(--gi,(byte)'0'); - buffer.setGetIndex(gi); - } - else - { - boolean minus=false; - if (n<0) - { - minus=true; - n=-n; - } - - int gi=buffer.getIndex(); - while(n>0) - { - int d = 0xf&n; - n=n>>4; - buffer.poke(--gi,DIGIT[d]); - } - - if (minus) - buffer.poke(--gi,(byte)'-'); - buffer.setGetIndex(gi); - } - } - + started= true; + int d= n / hexDivisors[i]; + buffer.put(DIGIT[d]); + n= n - d * hexDivisors[i]; + } + } + } - /* ------------------------------------------------------------ */ - public static void putDecInt(Buffer buffer, int n) - { - if (n < 0) - { - buffer.put((byte)'-'); - - if (n == Integer.MIN_VALUE) - { - buffer.put((byte)'2'); - n= 147483648; - } - else - n= -n; - } + /* ------------------------------------------------------------ */ + /** + * Add hex integer BEFORE current getIndex. + * @param buffer + * @param n + */ + public static void prependHexInt(Buffer buffer, int n) + { + if (n==0) + { + int gi=buffer.getIndex(); + buffer.poke(--gi,(byte)'0'); + buffer.setGetIndex(gi); + } + else + { + boolean minus=false; + if (n<0) + { + minus=true; + n=-n; + } - if (n < 10) - { - buffer.put(DIGIT[n]); - } - else - { - boolean started= false; - // This assumes constant time int arithmatic - for (int i= 0; i < decDivisors.length; i++) - { - if (n < decDivisors[i]) - { - if (started) - buffer.put((byte)'0'); - continue; - } + int gi=buffer.getIndex(); + while(n>0) + { + int d = 0xf&n; + n=n>>4; + buffer.poke(--gi,DIGIT[d]); + } + + if (minus) + buffer.poke(--gi,(byte)'-'); + buffer.setGetIndex(gi); + } + } + - started= true; - int d= n / decDivisors[i]; - buffer.put(DIGIT[d]); - n= n - d * decDivisors[i]; - } - } - } - - public static void putDecLong(Buffer buffer, long n) - { - if (n < 0) - { - buffer.put((byte)'-'); + public static void putDecLong(Buffer buffer, long n) + { + if (n < 0) + { + buffer.put((byte)'-'); + + if (n == Long.MIN_VALUE) + { + buffer.put((byte)'9'); + n= 223372036854775808L; + } + else + n= -n; + } - if (n == Long.MIN_VALUE) - { - buffer.put((byte)'9'); - n= 223372036854775808L; - } - else - n= -n; - } + if (n < 10) + { + buffer.put(DIGIT[(int)n]); + } + else + { + boolean started= false; + // This assumes constant time int arithmatic + for (int i= 0; i < decDivisorsL.length; i++) + { + if (n < decDivisorsL[i]) + { + if (started) + buffer.put((byte)'0'); + continue; + } - if (n < 10) - { - buffer.put(DIGIT[(int)n]); - } - else - { - boolean started= false; - // This assumes constant time int arithmatic - for (int i= 0; i < decDivisorsL.length; i++) - { - if (n < decDivisorsL[i]) - { - if (started) - buffer.put((byte)'0'); - continue; - } - - started= true; - long d= n / decDivisorsL[i]; - buffer.put(DIGIT[(int)d]); - n= n - d * decDivisorsL[i]; - } - } - } - - public static Buffer toBuffer(long value) - { - ByteArrayBuffer buf=new ByteArrayBuffer(32); - putDecLong(buf, value); - return buf; - } + started= true; + long d= n / decDivisorsL[i]; + buffer.put(DIGIT[(int)d]); + n= n - d * decDivisorsL[i]; + } + } + } + + public static Buffer toBuffer(long value) + { + ByteArrayBuffer buf=new ByteArrayBuffer(32); + putDecLong(buf, value); + return buf; + } - private final static int[] decDivisors= - { - 1000000000, - 100000000, - 10000000, - 1000000, - 100000, - 10000, - 1000, - 100, - 10, - 1 - }; + private final static int[] hexDivisors= + { + 0x10000000, + 0x1000000, + 0x100000, + 0x10000, + 0x1000, + 0x100, + 0x10, + 0x1 + }; - private final static int[] hexDivisors= - { - 0x10000000, - 0x1000000, - 0x100000, - 0x10000, - 0x1000, - 0x100, - 0x10, - 0x1 - }; - - private final static long[] decDivisorsL= - { - 1000000000000000000L, - 100000000000000000L, - 10000000000000000L, - 1000000000000000L, - 100000000000000L, - 10000000000000L, - 1000000000000L, - 100000000000L, - 10000000000L, - 1000000000L, - 100000000L, - 10000000L, - 1000000L, - 100000L, - 10000L, - 1000L, - 100L, - 10L, - 1L - }; + private final static long[] decDivisorsL= + { + 1000000000000000000L, + 100000000000000000L, + 10000000000000000L, + 1000000000000000L, + 100000000000000L, + 10000000000000L, + 1000000000000L, + 100000000000L, + 10000000000L, + 1000000000L, + 100000000L, + 10000000L, + 1000000L, + 100000L, + 10000L, + 1000L, + 100L, + 10L, + 1L + }; - public static void putCRLF(Buffer buffer) - { - buffer.put((byte)13); - buffer.put((byte)10); - } - - public static boolean isPrefix(Buffer prefix,Buffer buffer) - { - if (prefix.length()>buffer.length()) - return false; - int bi=buffer.getIndex(); - for (int i=prefix.getIndex(); i<prefix.putIndex();i++) - if (prefix.peek(i)!=buffer.peek(bi++)) - return false; - return true; - } + public static void putCRLF(Buffer buffer) + { + buffer.put((byte)13); + buffer.put((byte)10); + } + + public static boolean isPrefix(Buffer prefix,Buffer buffer) + { + if (prefix.length()>buffer.length()) + return false; + int bi=buffer.getIndex(); + for (int i=prefix.getIndex(); i<prefix.putIndex();i++) + if (prefix.peek(i)!=buffer.peek(bi++)) + return false; + return true; + } - public static String to8859_1_String(Buffer buffer) - { - if (buffer instanceof CachedBuffer) - return buffer.toString(); - return buffer.toString(StringUtil.__ISO_8859_1_CHARSET); - } + public static String to8859_1_String(Buffer buffer) + { + if (buffer instanceof CachedBuffer) + return buffer.toString(); + return buffer.toString(StringUtil.__ISO_8859_1_CHARSET); + } }
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/io/ByteArrayBuffer.java --- a/src/org/eclipse/jetty/io/ByteArrayBuffer.java Mon Oct 24 01:56:08 2016 -0600 +++ b/src/org/eclipse/jetty/io/ByteArrayBuffer.java Mon Oct 24 05:37:24 2016 -0600 @@ -25,10 +25,7 @@ import org.eclipse.jetty.util.StringUtil; -/* ------------------------------------------------------------------------------- */ -/** - * - */ + public class ByteArrayBuffer extends AbstractBuffer { // Set a maximum size to a write for the writeTo method, to ensure that very large content is not @@ -382,7 +379,6 @@ return total; } - /* ------------------------------------------------------------ */ @Override public int space() { @@ -390,9 +386,6 @@ } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ public static class CaseInsensitive extends ByteArrayBuffer implements Buffer.CaseInsensitve { public CaseInsensitive(String s)
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/server/Response.java --- a/src/org/eclipse/jetty/server/Response.java Mon Oct 24 01:56:08 2016 -0600 +++ b/src/org/eclipse/jetty/server/Response.java Mon Oct 24 05:37:24 2016 -0600 @@ -38,7 +38,6 @@ import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeaderValues; import org.eclipse.jetty.http.HttpHeaders; -import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.HttpVersions;
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/server/ssl/SslCertificates.java --- a/src/org/eclipse/jetty/server/ssl/SslCertificates.java Mon Oct 24 01:56:08 2016 -0600 +++ b/src/org/eclipse/jetty/server/ssl/SslCertificates.java Mon Oct 24 05:37:24 2016 -0600 @@ -26,7 +26,6 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; -import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.util.TypeUtil; @@ -102,7 +101,7 @@ */ public static void customize(SSLSession sslSession, EndPoint endpoint, Request request) throws IOException { - request.setScheme(HttpSchemes.HTTPS); + request.setScheme("https"); try {
diff -r d2c3ff33387c -r 4dc1e1a18661 src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java --- a/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Mon Oct 24 01:56:08 2016 -0600 +++ b/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Mon Oct 24 05:37:24 2016 -0600 @@ -26,7 +26,6 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; -import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffers; @@ -109,7 +108,7 @@ @Override public void customize(AbstractHttpConnection con) throws IOException { - con._request.setScheme(HttpSchemes.HTTPS); + con._request.setScheme("https"); super.customize(con); SslConnection.SslEndPoint sslEndpoint=(SslConnection.SslEndPoint)con._endp;