Use the method getContextURL rather than getSecureContextURL in the getCapacities method.So if the server doesn't support sll, the getCapacities will return a baseURL with http.
Use the method getContextURL rather than getSecureContextURL in the getCapacities method.
So if the server doesn't support sll, the getCapacities will return a baseURL with http.