public URL normalizeURI(URI relativeOrAbsoluteURI) { // TODO: I have one device (Netgear 834DG DSL Router) that sends a <URLBase>, and even that is wrong (port)! // This can be fixed by "re-enabling" UPnP in the upnpService after a reboot, it will then use the right port... // return URIUtil.createAbsoluteURL(getDescriptorURL(), relativeOrAbsoluteURI); if (getDetails() != null && getDetails().getBaseURL() != null) { // If we have an <URLBase>, all URIs are relative to it return URIUtil.createAbsoluteURL(getDetails().getBaseURL(), relativeOrAbsoluteURI); } else { // Otherwise, they are relative to the descriptor location return URIUtil.createAbsoluteURL(getIdentity().getDescriptorURL(), relativeOrAbsoluteURI); } }
/** * @return An HTTP URL with the address, port, and path of this location. */ public URL getURL() { return URIUtil.createAbsoluteURL(networkAddress.getAddress(), networkAddress.getPort(), path); }
public URL normalizeURI(URI relativeOrAbsoluteURI) { // TODO: I have one device (Netgear 834DG DSL Router) that sends a <URLBase>, and even that is wrong (port)! // This can be fixed by "re-enabling" UPnP in the upnpService after a reboot, it will then use the right port... // return URIUtil.createAbsoluteURL(getDescriptorURL(), relativeOrAbsoluteURI); if (getDetails() != null && getDetails().getBaseURL() != null) { // If we have an <URLBase>, all URIs are relative to it return URIUtil.createAbsoluteURL(getDetails().getBaseURL(), relativeOrAbsoluteURI); } else { // Otherwise, they are relative to the descriptor location return URIUtil.createAbsoluteURL(getIdentity().getDescriptorURL(), relativeOrAbsoluteURI); } }
public static URL createAbsoluteURL(URL base, String uri) throws IllegalArgumentException { return createAbsoluteURL(base, URI.create(uri)); }
public static URL createAbsoluteURL(InetAddress address, int localStreamPort, URI relativeOrNot) throws IllegalArgumentException { try { if (address instanceof Inet6Address) { return createAbsoluteURL(new URL("http://[" + address.getHostAddress() + "]:" + localStreamPort), relativeOrNot); } else if (address instanceof Inet4Address) { return createAbsoluteURL(new URL("http://" + address.getHostAddress() + ":" + localStreamPort), relativeOrNot); } else { throw new IllegalArgumentException("InetAddress is neither IPv4 nor IPv6: " + address); } } catch (Exception ex) { throw new IllegalArgumentException("Address, port, and URI can not be converted to URL", ex); } }
public URL normalizeURI(URI relativeOrAbsoluteURI) { // TODO: I have one device (Netgear 834DG DSL Router) that sends a <URLBase>, and even that is wrong (port)! // This can be fixed by "re-enabling" UPnP in the upnpService after a reboot, it will then use the right port... // return URIUtil.createAbsoluteURL(getDescriptorURL(), relativeOrAbsoluteURI); if (getDetails() != null && getDetails().getBaseURL() != null) { // If we have an <URLBase>, all URIs are relative to it return URIUtil.createAbsoluteURL(getDetails().getBaseURL(), relativeOrAbsoluteURI); } else { // Otherwise, they are relative to the descriptor location return URIUtil.createAbsoluteURL(getIdentity().getDescriptorURL(), relativeOrAbsoluteURI); } }