Mercurial Hosting > luan
comparison src/org/eclipse/jetty/http/HttpGenerator.java @ 1019:f126d30e04a4
start replacing BufferCache with StringCache
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 31 Oct 2016 03:33:42 -0600 |
| parents | 83cc6e05a58f |
| children | 6be43ef1eb96 |
comparison
equal
deleted
inserted
replaced
| 1018:4dc1e1a18661 | 1019:f126d30e04a4 |
|---|---|
| 51 Buffer _responseLine; | 51 Buffer _responseLine; |
| 52 } | 52 } |
| 53 private static final Status[] __status = new Status[HttpStatus.MAX_CODE+1]; | 53 private static final Status[] __status = new Status[HttpStatus.MAX_CODE+1]; |
| 54 static | 54 static |
| 55 { | 55 { |
| 56 int versionLength=HttpVersions.HTTP_1_1_BUFFER.length(); | 56 final int versionLength=HttpVersions.HTTP_1_1_BYTES.length; |
| 57 | 57 |
| 58 for (int i=0;i<__status.length;i++) | 58 for (int i=0;i<__status.length;i++) |
| 59 { | 59 { |
| 60 HttpStatus.Code code = HttpStatus.getCode(i); | 60 HttpStatus.Code code = HttpStatus.getCode(i); |
| 61 if (code==null) | 61 if (code==null) |
| 62 continue; | 62 continue; |
| 63 String reason=code.getMessage(); | 63 String reason=code.getMessage(); |
| 64 byte[] bytes=new byte[versionLength+5+reason.length()+2]; | 64 byte[] bytes=new byte[versionLength+5+reason.length()+2]; |
| 65 HttpVersions.HTTP_1_1_BUFFER.peek(0,bytes, 0, versionLength); | 65 // HttpVersions.HTTP_1_1_BUFFER.peek(0,bytes, 0, versionLength); |
| 66 System.arraycopy(HttpVersions.HTTP_1_1_BYTES,0,bytes,0,versionLength); | |
| 66 bytes[versionLength+0]=' '; | 67 bytes[versionLength+0]=' '; |
| 67 bytes[versionLength+1]=(byte)('0'+i/100); | 68 bytes[versionLength+1]=(byte)('0'+i/100); |
| 68 bytes[versionLength+2]=(byte)('0'+(i%100)/10); | 69 bytes[versionLength+2]=(byte)('0'+(i%100)/10); |
| 69 bytes[versionLength+3]=(byte)('0'+(i%10)); | 70 bytes[versionLength+3]=(byte)('0'+(i%10)); |
| 70 bytes[versionLength+4]=' '; | 71 bytes[versionLength+4]=' '; |
| 347 { | 348 { |
| 348 _header.put(_method); | 349 _header.put(_method); |
| 349 _header.put((byte)' '); | 350 _header.put((byte)' '); |
| 350 _header.put(_uri.getBytes("UTF-8")); // TODO check | 351 _header.put(_uri.getBytes("UTF-8")); // TODO check |
| 351 _header.put((byte)' '); | 352 _header.put((byte)' '); |
| 352 _header.put(_version==HttpVersions.HTTP_1_0_ORDINAL?HttpVersions.HTTP_1_0_BUFFER:HttpVersions.HTTP_1_1_BUFFER); | 353 _header.put(_version==HttpVersions.HTTP_1_0_ORDINAL?HttpVersions.HTTP_1_0_BYTES:HttpVersions.HTTP_1_1_BYTES); |
| 353 _header.put(HttpTokens.CRLF); | 354 _header.put(HttpTokens.CRLF); |
| 354 } | 355 } |
| 355 } | 356 } |
| 356 else | 357 else |
| 357 { | 358 { |
| 371 // add response line | 372 // add response line |
| 372 Status status = _status<__status.length?__status[_status]:null; | 373 Status status = _status<__status.length?__status[_status]:null; |
| 373 | 374 |
| 374 if (status==null) | 375 if (status==null) |
| 375 { | 376 { |
| 376 _header.put(HttpVersions.HTTP_1_1_BUFFER); | 377 _header.put(HttpVersions.HTTP_1_1_BYTES); |
| 377 _header.put((byte) ' '); | 378 _header.put((byte) ' '); |
| 378 _header.put((byte) ('0' + _status / 100)); | 379 _header.put((byte) ('0' + _status / 100)); |
| 379 _header.put((byte) ('0' + (_status % 100) / 10)); | 380 _header.put((byte) ('0' + (_status % 100) / 10)); |
| 380 _header.put((byte) ('0' + (_status % 10))); | 381 _header.put((byte) ('0' + (_status % 10))); |
| 381 _header.put((byte) ' '); | 382 _header.put((byte) ' '); |
