Mercurial Hosting > luan
comparison src/org/eclipse/jetty/http/HttpParser.java @ 1022:3718afd99988
HttpHeaders uses StringCache
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 01 Nov 2016 01:04:46 -0600 |
parents | e350c11242be |
children | cf0367978d8b |
comparison
equal
deleted
inserted
replaced
1021:e350c11242be | 1022:3718afd99988 |
---|---|
19 package org.eclipse.jetty.http; | 19 package org.eclipse.jetty.http; |
20 | 20 |
21 import java.io.IOException; | 21 import java.io.IOException; |
22 | 22 |
23 import org.eclipse.jetty.io.Buffer; | 23 import org.eclipse.jetty.io.Buffer; |
24 import org.eclipse.jetty.io.BufferCache.CachedBuffer; | |
25 import org.eclipse.jetty.io.BufferUtil; | 24 import org.eclipse.jetty.io.BufferUtil; |
26 import org.eclipse.jetty.io.Buffers; | 25 import org.eclipse.jetty.io.Buffers; |
27 import org.eclipse.jetty.io.ByteArrayBuffer; | 26 import org.eclipse.jetty.io.ByteArrayBuffer; |
28 import org.eclipse.jetty.io.EndPoint; | 27 import org.eclipse.jetty.io.EndPoint; |
29 import org.eclipse.jetty.io.EofException; | 28 import org.eclipse.jetty.io.EofException; |
64 private final Buffers _buffers; // source of buffers | 63 private final Buffers _buffers; // source of buffers |
65 private final EndPoint _endp; | 64 private final EndPoint _endp; |
66 private Buffer _header; // Buffer for header data (and small _content) | 65 private Buffer _header; // Buffer for header data (and small _content) |
67 private Buffer _body; // Buffer for large content | 66 private Buffer _body; // Buffer for large content |
68 private Buffer _buffer; // The current buffer in use (either _header or _content) | 67 private Buffer _buffer; // The current buffer in use (either _header or _content) |
69 private CachedBuffer _cached; | 68 private String _cached; |
70 private String _tok0; // Saved token: header name, request method or response version | 69 private String _tok0; // Saved token: header name, request method or response version |
71 private final View.CaseInsensitive _tok1 = new View.CaseInsensitive(); // Saved token: header value, request URI or response code | 70 private final View.CaseInsensitive _tok1 = new View.CaseInsensitive(); // Saved token: header value, request URI or response code |
72 private String _multiLineValue; | 71 private String _multiLineValue; |
73 private int _responseStatus; // If >0 then we are parsing a response | 72 private int _responseStatus; // If >0 then we are parsing a response |
74 private boolean _persistent; | 73 private boolean _persistent; |
434 default: | 433 default: |
435 { | 434 { |
436 // handler last header if any | 435 // handler last header if any |
437 if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null) | 436 if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null) |
438 { | 437 { |
439 String header = _cached!=null?_cached.toString():_tok0; | 438 String header = _cached!=null ? _cached : _tok0; |
440 _cached = null; | 439 _cached = null; |
441 String value = _multiLineValue == null ? _tok1.toString() : _multiLineValue; | 440 String value = _multiLineValue == null ? _tok1.toString() : _multiLineValue; |
442 | 441 |
443 int ho = HttpHeaders.CACHE.getOrdinal(header); | 442 int ho = HttpHeaders.CACHE.getOrdinal(header); |
444 if (ho >= 0) | 443 if (ho >= 0) |
580 _state = STATE_HEADER_NAME; | 579 _state = STATE_HEADER_NAME; |
581 | 580 |
582 // try cached name! | 581 // try cached name! |
583 if (array!=null) | 582 if (array!=null) |
584 { | 583 { |
585 _cached = HttpHeaders.CACHE.getBest(array, _buffer.markIndex(), length+1); | 584 String s = new String(array, _buffer.markIndex(), length+1); |
585 _cached = HttpHeaders.CACHE.getBest(s); | |
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); |