View | Details | Raw Unified | Return to bug 64267
Collapse All | Expand All

(-)a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (-7 / +20 lines)
Lines 255-273 public class HTTPHC4Impl extends HTTPHCAbstractImpl { Link Here
255
                    if (!authScope.getRealm().equals(auth.getRealm())) {
255
                    if (!authScope.getRealm().equals(auth.getRealm())) {
256
                        continue;
256
                        continue;
257
                    }
257
                    }
258
                    try {
258
                    if (matchesOnUrl(authScope, auth)) {
259
                        URL authUrl = new URL(auth.getURL());
259
                        return auth;
260
                        if (authUrl.getHost().equals(authScope.getHost()) && getPort(authUrl) == authScope.getPort()) {
261
                            return auth;
262
                        }
263
                    } catch (MalformedURLException e) {
264
                        log.debug("Invalid URL {} in authManager", auth.getURL());
265
                    }
260
                    }
266
                }
261
                }
267
            }
262
            }
268
            return null;
263
            return null;
269
        }
264
        }
270
265
266
        private boolean matchesOnUrl(AuthScope authScope, Authorization auth) {
267
            String authUrlString = auth.getURL().toLowerCase();
268
            try {
269
                URL authUrl = new URL(authUrlString);
270
                if (authUrl.getHost().equals(authScope.getHost()) && getPort(authUrl) == authScope.getPort()) {
271
                    return true;
272
                }
273
            } catch (MalformedURLException e) {
274
                for (String prefix: Arrays.asList("http://", "https://")) {
275
                    if ((prefix + authScope.getHost() + ":" + authScope.getPort()).startsWith(authUrlString)) {
276
                        return true;
277
                    }
278
                }
279
                log.debug("Invalid URL {} in authManager", authUrlString);
280
            }
281
            return false;
282
        }
283
271
        private int getPort(URL url) {
284
        private int getPort(URL url) {
272
            if (url.getPort() == -1) {
285
            if (url.getPort() == -1) {
273
                return url.getProtocol().equals("https") ? 443 : 80;
286
                return url.getProtocol().equals("https") ? 443 : 80;

Return to bug 64267