Map the specified URI. @throws IOException If an error occurs while manipulating the URI during the mapping
(CharChunk host, CharChunk uri, String version, MappingData mappingData)
| 728 | * @throws IOException If an error occurs while manipulating the URI during the mapping |
| 729 | */ |
| 730 | private void internalMap(CharChunk host, CharChunk uri, String version, MappingData mappingData) |
| 731 | throws IOException { |
| 732 | |
| 733 | if (mappingData.host != null) { |
| 734 | // The legacy code (dating down at least to Tomcat 4.1) just |
| 735 | // skipped all mapping work in this case. That behaviour has a risk |
| 736 | // of returning an inconsistent result. |
| 737 | // I do not see a valid use case for it. |
| 738 | throw new IllegalStateException(sm.getString("mapper.alreadyDone", mappingData)); |
| 739 | } |
| 740 | |
| 741 | // Virtual host mapping |
| 742 | MappedHost[] hosts = this.hosts; |
| 743 | MappedHost mappedHost = exactFindIgnoreCase(hosts, host); |
| 744 | if (mappedHost == null) { |
| 745 | // Note: Internally, the Mapper does not use the leading * on a |
| 746 | // wildcard host. This is to allow this shortcut. |
| 747 | int firstDot = host.indexOf('.'); |
| 748 | if (firstDot > -1) { |
| 749 | int start = host.getStart(); |
| 750 | try { |
| 751 | host.setStart(firstDot + start); |
| 752 | mappedHost = exactFindIgnoreCase(hosts, host); |
| 753 | } finally { |
| 754 | // Make absolutely sure this gets reset |
| 755 | host.setStart(start); |
| 756 | } |
| 757 | } |
| 758 | if (mappedHost == null) { |
| 759 | mappedHost = defaultHost; |
| 760 | if (mappedHost == null) { |
| 761 | return; |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | mappingData.host = mappedHost.object; |
| 766 | |
| 767 | if (uri.isNull()) { |
| 768 | // Can't map context or wrapper without a uri |
| 769 | return; |
| 770 | } |
| 771 | |
| 772 | uri.setLimit(-1); |
| 773 | |
| 774 | // Context mapping |
| 775 | ContextList contextList = mappedHost.contextList; |
| 776 | MappedContext[] contexts = contextList.contexts; |
| 777 | int pos = find(contexts, uri); |
| 778 | if (pos == -1) { |
| 779 | return; |
| 780 | } |
| 781 | |
| 782 | int lastSlash = -1; |
| 783 | int uriEnd = uri.getEnd(); |
| 784 | boolean found = false; |
| 785 | MappedContext context = null; |
| 786 | while (pos >= 0) { |
| 787 | context = contexts[pos]; |
no test coverage detected