comparison src/org/eclipse/jetty/http/HttpParser.java @ 1063:0157e92670f5

remove JBuffer.getIndex()
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 09 Nov 2016 02:08:33 -0700
parents c880589715c7
children 158d1e6ac17f
comparison
equal deleted inserted replaced
1062:4a50422596b6 1063:0157e92670f5
84 _endp = endp; 84 _endp = endp;
85 _handler = handler; 85 _handler = handler;
86 } 86 }
87 87
88 private void mark() { 88 private void mark() {
89 _mark = _buffer.getIndex() - 1; 89 _mark = _buffer.position() - 1;
90 } 90 }
91 91
92 private String sliceFromMark() { 92 private String sliceFromMark() {
93 JBuffer buf = _buffer.duplicate(); 93 JBuffer buf = _buffer.duplicate();
94 buf.position(_mark); 94 buf.position(_mark);
104 104
105 private void compact() { 105 private void compact() {
106 if( _mark == -1 ) { 106 if( _mark == -1 ) {
107 _buffer.compact(); 107 _buffer.compact();
108 } else if( _mark > 0 ) { 108 } else if( _mark > 0 ) {
109 int old = _buffer.getIndex(); 109 int old = _buffer.position();
110 _buffer.position(_mark); 110 _buffer.position(_mark);
111 _buffer.compact(); 111 _buffer.compact();
112 _buffer.position( old - _mark ); 112 _buffer.position( old - _mark );
113 _mark = 0; 113 _mark = 0;
114 } 114 }
333 break; 333 break;
334 334
335 case STATE_FIELD0: 335 case STATE_FIELD0:
336 if (ch == HttpTokens.SPACE) 336 if (ch == HttpTokens.SPACE)
337 { 337 {
338 _tok0 = bufferToString(_mark, _buffer.getIndex() - 1 - _mark); 338 _tok0 = bufferToString(_mark, _buffer.position() - 1 - _mark);
339 _responseStatus = !HttpVersions.CACHE.contains(_tok0)?-1:0; 339 _responseStatus = !HttpVersions.CACHE.contains(_tok0)?-1:0;
340 _state=STATE_SPACE1; 340 _state=STATE_SPACE1;
341 continue; 341 continue;
342 } 342 }
343 else if (ch < HttpTokens.SPACE && ch>=0) 343 else if (ch < HttpTokens.SPACE && ch>=0)
365 break; 365 break;
366 366
367 case STATE_STATUS: 367 case STATE_STATUS:
368 if (ch == HttpTokens.SPACE) 368 if (ch == HttpTokens.SPACE)
369 { 369 {
370 // _tok1.update(_mark, _buffer.getIndex() - 1); 370 _tok1 = bufferToString(_mark, _buffer.position() - 1 - _mark);
371 _tok1 = bufferToString(_mark, _buffer.getIndex() - 1 - _mark);
372 _state = STATE_SPACE2; 371 _state = STATE_SPACE2;
373 continue; 372 continue;
374 } 373 }
375 else if (ch>='0' && ch<='9') 374 else if (ch>='0' && ch<='9')
376 { 375 {
392 break; 391 break;
393 392
394 case STATE_URI: 393 case STATE_URI:
395 if (ch == HttpTokens.SPACE) 394 if (ch == HttpTokens.SPACE)
396 { 395 {
397 // _tok1.update(_mark, _buffer.getIndex() - 1); 396 _tok1 = bufferToString(_mark, _buffer.position() - 1 - _mark);
398 _tok1 = bufferToString(_mark, _buffer.getIndex() - 1 - _mark);
399 _state=STATE_SPACE2; 397 _state=STATE_SPACE2;
400 continue; 398 continue;
401 } 399 }
402 else if (ch < HttpTokens.SPACE && ch>=0) 400 else if (ch < HttpTokens.SPACE && ch>=0)
403 { 401 {
662 default: 660 default:
663 { 661 {
664 _cached = null; 662 _cached = null;
665 if (_length == -1) 663 if (_length == -1)
666 mark(); 664 mark();
667 _length=_buffer.getIndex() - _mark; 665 _length = _buffer.position() - _mark;
668 _state = STATE_HEADER_IN_NAME; 666 _state = STATE_HEADER_IN_NAME;
669 } 667 }
670 } 668 }
671 669
672 break; 670 break;
728 break; 726 break;
729 default: 727 default:
730 { 728 {
731 if (_length == -1) 729 if (_length == -1)
732 mark(); 730 mark();
733 _length=_buffer.getIndex() - _mark; 731 _length = _buffer.position() - _mark;
734 _state = STATE_HEADER_IN_VALUE; 732 _state = STATE_HEADER_IN_VALUE;
735 } 733 }
736 } 734 }
737 break; 735 break;
738 736