MCPcopy Index your code
hub / github.com/apache/tomcat / internalMap

Method internalMap

java/org/apache/catalina/mapper/Mapper.java:730–845  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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];

Callers 1

mapMethod · 0.95

Calls 15

exactFindIgnoreCaseMethod · 0.95
findMethod · 0.95
nthSlashMethod · 0.95
lastSlashMethod · 0.95
exactFindMethod · 0.95
isPausedMethod · 0.95
internalMapWrapperMethod · 0.95
setStartMethod · 0.80
lengthMethod · 0.80
setEndMethod · 0.80
getStringMethod · 0.65
isNullMethod · 0.65

Tested by

no test coverage detected