Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/AbstractHttpConnection.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 |
---|---|
501 throw (HttpException)e; | 501 throw (HttpException)e; |
502 throw new HttpException(HttpStatus.BAD_REQUEST_400,null,e); | 502 throw new HttpException(HttpStatus.BAD_REQUEST_400,null,e); |
503 } | 503 } |
504 } | 504 } |
505 | 505 |
506 private void parsedHeader(Buffer name, Buffer value) throws IOException | 506 private void parsedHeader(Buffer name, String value) throws IOException |
507 { | 507 { |
508 int ho = HttpHeaders.CACHE.getOrdinal(name); | 508 int ho = HttpHeaders.CACHE.getOrdinal(name); |
509 switch (ho) | 509 switch (ho) |
510 { | 510 { |
511 case HttpHeaders.HOST_ORDINAL: | 511 case HttpHeaders.HOST_ORDINAL: |
514 break; | 514 break; |
515 | 515 |
516 case HttpHeaders.EXPECT_ORDINAL: | 516 case HttpHeaders.EXPECT_ORDINAL: |
517 if (_version>=HttpVersions.HTTP_1_1_ORDINAL) | 517 if (_version>=HttpVersions.HTTP_1_1_ORDINAL) |
518 { | 518 { |
519 value = HttpHeaderValues.CACHE.lookup(value); | 519 // value = HttpHeaderValues.CACHE.lookup(value); |
520 switch(HttpHeaderValues.CACHE.getOrdinal(value)) | 520 switch(HttpHeaderValues.CACHE.getOrdinal(value)) |
521 { | 521 { |
522 case HttpHeaderValues.CONTINUE_ORDINAL: | 522 case HttpHeaderValues.CONTINUE_ORDINAL: |
523 _expect100Continue = true; | 523 _expect100Continue = true; |
524 break; | 524 break; |
525 | 525 |
526 default: | 526 default: |
527 String[] values = value.toString().split(","); | 527 String[] values = value.toString().split(","); |
528 for (int i=0;values!=null && i<values.length;i++) | 528 for (int i=0;values!=null && i<values.length;i++) |
529 { | 529 { |
530 CachedBuffer cb=HttpHeaderValues.CACHE.get(values[i].trim()); | 530 int cb = HttpHeaderValues.CACHE.getOrdinal(values[i].trim()); |
531 if (cb==null) | 531 if (cb == -1) |
532 _expect = true; | 532 _expect = true; |
533 else | 533 else |
534 { | 534 { |
535 switch(cb.getOrdinal()) | 535 switch(cb) |
536 { | 536 { |
537 case HttpHeaderValues.CONTINUE_ORDINAL: | 537 case HttpHeaderValues.CONTINUE_ORDINAL: |
538 _expect100Continue = true; | 538 _expect100Continue = true; |
539 break; | 539 break; |
540 default: | 540 default: |
546 } | 546 } |
547 break; | 547 break; |
548 | 548 |
549 case HttpHeaders.ACCEPT_ENCODING_ORDINAL: | 549 case HttpHeaders.ACCEPT_ENCODING_ORDINAL: |
550 case HttpHeaders.USER_AGENT_ORDINAL: | 550 case HttpHeaders.USER_AGENT_ORDINAL: |
551 value = HttpHeaderValues.CACHE.lookup(value); | 551 // value = HttpHeaderValues.CACHE.lookup(value); |
552 break; | 552 break; |
553 | 553 |
554 case HttpHeaders.CONTENT_TYPE_ORDINAL: | 554 case HttpHeaders.CONTENT_TYPE_ORDINAL: |
555 value = MimeTypes.CACHE.lookup(value); | 555 // value = MimeTypes.CACHE.lookup(value); |
556 _charset=MimeTypes.getCharsetFromContentType(value); | 556 _charset=MimeTypes.getCharsetFromContentType(new ByteArrayBuffer(value)); |
557 break; | 557 break; |
558 } | 558 } |
559 | 559 |
560 _requestFields.add(name, value); | 560 _requestFields.add(name, value); |
561 } | 561 } |
576 break; | 576 break; |
577 case HttpVersions.HTTP_1_0_ORDINAL: | 577 case HttpVersions.HTTP_1_0_ORDINAL: |
578 _generator.setHead(_head); | 578 _generator.setHead(_head); |
579 if (_parser.isPersistent()) | 579 if (_parser.isPersistent()) |
580 { | 580 { |
581 _responseFields.add(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.KEEP_ALIVE_BUFFER); | 581 _responseFields.add(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.KEEP_ALIVE); |
582 _generator.setPersistent(true); | 582 _generator.setPersistent(true); |
583 } | 583 } |
584 else if (HttpMethods.CONNECT.equals(_request.getMethod())) | 584 else if (HttpMethods.CONNECT.equals(_request.getMethod())) |
585 { | 585 { |
586 _generator.setPersistent(true); | 586 _generator.setPersistent(true); |
591 case HttpVersions.HTTP_1_1_ORDINAL: | 591 case HttpVersions.HTTP_1_1_ORDINAL: |
592 _generator.setHead(_head); | 592 _generator.setHead(_head); |
593 | 593 |
594 if (!_parser.isPersistent()) | 594 if (!_parser.isPersistent()) |
595 { | 595 { |
596 _responseFields.add(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE_BUFFER); | 596 _responseFields.add(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE); |
597 _generator.setPersistent(false); | 597 _generator.setPersistent(false); |
598 } | 598 } |
599 | 599 |
600 if (!_host) | 600 if (!_host) |
601 { | 601 { |
602 LOG.debug("!host {}",this); | 602 LOG.debug("!host {}",this); |
603 _generator.setResponse(HttpStatus.BAD_REQUEST_400, null); | 603 _generator.setResponse(HttpStatus.BAD_REQUEST_400, null); |
604 _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER); | 604 _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE); |
605 _generator.completeHeader(_responseFields, true); | 605 _generator.completeHeader(_responseFields, true); |
606 _generator.complete(); | 606 _generator.complete(); |
607 return; | 607 return; |
608 } | 608 } |
609 | 609 |
610 if (_expect) | 610 if (_expect) |
611 { | 611 { |
612 LOG.debug("!expectation {}",this); | 612 LOG.debug("!expectation {}",this); |
613 _generator.setResponse(HttpStatus.EXPECTATION_FAILED_417, null); | 613 _generator.setResponse(HttpStatus.EXPECTATION_FAILED_417, null); |
614 _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER); | 614 _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE); |
615 _generator.completeHeader(_responseFields, true); | 615 _generator.completeHeader(_responseFields, true); |
616 _generator.complete(); | 616 _generator.complete(); |
617 return; | 617 return; |
618 } | 618 } |
619 | 619 |
662 { | 662 { |
663 AbstractHttpConnection.this.startRequest(method, uri, version); | 663 AbstractHttpConnection.this.startRequest(method, uri, version); |
664 } | 664 } |
665 | 665 |
666 @Override | 666 @Override |
667 public void parsedHeader(Buffer name, Buffer value) throws IOException | 667 public void parsedHeader(Buffer name, String value) throws IOException |
668 { | 668 { |
669 AbstractHttpConnection.this.parsedHeader(name, value); | 669 AbstractHttpConnection.this.parsedHeader(name, value); |
670 } | 670 } |
671 | 671 |
672 @Override | 672 @Override |