comparison src/org/eclipse/jetty/http/HttpParser.java @ 1021:e350c11242be

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 22:49:25 -0600
parents 6be43ef1eb96
children 3718afd99988
comparison
equal deleted inserted replaced
1020:6be43ef1eb96 1021:e350c11242be
276 _eol=0; 276 _eol=0;
277 277
278 switch (_state) 278 switch (_state)
279 { 279 {
280 case STATE_START: 280 case STATE_START:
281 _contentLength=HttpTokens.UNKNOWN_CONTENT; 281 _contentLength = HttpTokens.UNKNOWN_CONTENT;
282 _cached=null; 282 _cached = null;
283 if (ch > HttpTokens.SPACE || ch<0) 283 if (ch > HttpTokens.SPACE || ch<0)
284 { 284 {
285 _buffer.mark(); 285 _buffer.mark();
286 _state=STATE_FIELD0; 286 _state=STATE_FIELD0;
287 } 287 }
434 default: 434 default:
435 { 435 {
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 String header = _cached!=null?_cached.toString():_tok0;
440 _cached=null; 440 _cached = null;
441 String value = _multiLineValue == null ? _tok1.toString() : _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;
447 447
448 switch (ho) 448 switch (ho)
573 return 1; 573 return 1;
574 } 574 }
575 else 575 else
576 { 576 {
577 // New header 577 // New header
578 _length=1; 578 _length = 1;
579 _buffer.mark(); 579 _buffer.mark();
580 _state=STATE_HEADER_NAME; 580 _state = STATE_HEADER_NAME;
581 581
582 // try cached name! 582 // try cached name!
583 if (array!=null) 583 if (array!=null)
584 { 584 {
585 _cached=HttpHeaders.CACHE.getBest(array, _buffer.markIndex(), length+1); 585 _cached = HttpHeaders.CACHE.getBest(array, _buffer.markIndex(), length+1);
586 586
587 if (_cached!=null) 587 if (_cached!=null)
588 { 588 {
589 _length=_cached.length(); 589 _length = _cached.length();
590 _buffer.setGetIndex(_buffer.markIndex()+_length); 590 _buffer.setGetIndex(_buffer.markIndex()+_length);
591 length=_buffer.length(); 591 length = _buffer.length();
592 } 592 }
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
624 case HttpTokens.SPACE: 624 case HttpTokens.SPACE:
625 case HttpTokens.TAB: 625 case HttpTokens.TAB:
626 break; 626 break;
627 default: 627 default:
628 { 628 {
629 _cached=null; 629 _cached = null;
630 if (_length == -1) 630 if (_length == -1)
631 _buffer.mark(); 631 _buffer.mark();
632 _length=_buffer.getIndex() - _buffer.markIndex(); 632 _length=_buffer.getIndex() - _buffer.markIndex();
633 _state=STATE_HEADER_IN_NAME; 633 _state=STATE_HEADER_IN_NAME;
634 } 634 }
664 case HttpTokens.TAB: 664 case HttpTokens.TAB:
665 _state=STATE_HEADER_NAME; 665 _state=STATE_HEADER_NAME;
666 break; 666 break;
667 default: 667 default:
668 { 668 {
669 _cached=null; 669 _cached = null;
670 _length++; 670 _length++;
671 } 671 }
672 } 672 }
673 break; 673 break;
674 674
1140 public void messageComplete(long contentLength) throws IOException; 1140 public void messageComplete(long contentLength) throws IOException;
1141 1141
1142 /** 1142 /**
1143 * 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
1144 */ 1144 */
1145 public void parsedHeader(Buffer name, String value) throws IOException; 1145 public void parsedHeader(String name, String value) throws IOException;
1146 1146
1147 /** 1147 /**
1148 * 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
1149 */ 1149 */
1150 public abstract void startRequest(String method, Buffer url, String version) 1150 public abstract void startRequest(String method, Buffer url, String version)