comparison src/org/eclipse/jetty/http/HttpParser.java @ 1020:6be43ef1eb96

HttpHeaderValues uses StringCache
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 22:24:41 -0600
parents f126d30e04a4
children e350c11242be
comparison
equal deleted inserted replaced
1019:f126d30e04a4 1020:6be43ef1eb96
436 // handler last header if any 436 // handler last header if any
437 if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null) 437 if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null)
438 { 438 {
439 Buffer header=_cached!=null?_cached:HttpHeaders.CACHE.lookup(_tok0); 439 Buffer header=_cached!=null?_cached:HttpHeaders.CACHE.lookup(_tok0);
440 _cached=null; 440 _cached=null;
441 Buffer value=_multiLineValue == null ? _tok1 : new ByteArrayBuffer(_multiLineValue); 441 String value = _multiLineValue == null ? _tok1.toString() : _multiLineValue;
442 442
443 int ho=HttpHeaders.CACHE.getOrdinal(header); 443 int ho=HttpHeaders.CACHE.getOrdinal(header);
444 if (ho >= 0) 444 if (ho >= 0)
445 { 445 {
446 int vo; 446 int vo;
463 _contentLength=HttpTokens.NO_CONTENT; 463 _contentLength=HttpTokens.NO_CONTENT;
464 } 464 }
465 break; 465 break;
466 466
467 case HttpHeaders.TRANSFER_ENCODING_ORDINAL: 467 case HttpHeaders.TRANSFER_ENCODING_ORDINAL:
468 value=HttpHeaderValues.CACHE.lookup(value); 468 // value=HttpHeaderValues.CACHE.lookup(value);
469 vo=HttpHeaderValues.CACHE.getOrdinal(value); 469 vo = HttpHeaderValues.CACHE.getOrdinal(value);
470 if (HttpHeaderValues.CHUNKED_ORDINAL == vo) 470 if (HttpHeaderValues.CHUNKED_ORDINAL == vo)
471 _contentLength=HttpTokens.CHUNKED_CONTENT; 471 _contentLength=HttpTokens.CHUNKED_CONTENT;
472 else 472 else
473 { 473 {
474 String c=value.toString(StringUtil.__ISO_8859_1); 474 if (value.endsWith(HttpHeaderValues.CHUNKED))
475 if (c.endsWith(HttpHeaderValues.CHUNKED))
476 _contentLength=HttpTokens.CHUNKED_CONTENT; 475 _contentLength=HttpTokens.CHUNKED_CONTENT;
477 476
478 else if (c.indexOf(HttpHeaderValues.CHUNKED) >= 0) 477 else if (value.indexOf(HttpHeaderValues.CHUNKED) >= 0)
479 throw new HttpException(400,null); 478 throw new HttpException(400,null);
480 } 479 }
481 break; 480 break;
482 481
483 case HttpHeaders.CONNECTION_ORDINAL: 482 case HttpHeaders.CONNECTION_ORDINAL:
491 _persistent=true; 490 _persistent=true;
492 break; 491 break;
493 492
494 case -1: // No match, may be multi valued 493 case -1: // No match, may be multi valued
495 { 494 {
496 for (String v : value.toString().split(",")) 495 for (String v : value.split(","))
497 { 496 {
498 switch(HttpHeaderValues.CACHE.getOrdinal(v.trim())) 497 switch(HttpHeaderValues.CACHE.getOrdinal(v.trim()))
499 { 498 {
500 case HttpHeaderValues.CLOSE_ORDINAL: 499 case HttpHeaderValues.CLOSE_ORDINAL:
501 _persistent=false; 500 _persistent=false;
1141 public void messageComplete(long contentLength) throws IOException; 1140 public void messageComplete(long contentLength) throws IOException;
1142 1141
1143 /** 1142 /**
1144 * This is the method called by parser when a HTTP Header name and value is found 1143 * This is the method called by parser when a HTTP Header name and value is found
1145 */ 1144 */
1146 public void parsedHeader(Buffer name, Buffer value) throws IOException; 1145 public void parsedHeader(Buffer name, String value) throws IOException;
1147 1146
1148 /** 1147 /**
1149 * This is the method called by parser when the HTTP request line is parsed 1148 * This is the method called by parser when the HTTP request line is parsed
1150 */ 1149 */
1151 public abstract void startRequest(String method, Buffer url, String version) 1150 public abstract void startRequest(String method, Buffer url, String version)