diff --git a/src/org/openstreetmap/josm/tools/HttpClient.java b/src/org/openstreetmap/josm/tools/HttpClient.java
index 8d8fba38f7..ce5ddd94a2 100644
a
|
b
|
public abstract class HttpClient {
|
188 | 188 | throw new IOException(tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." + |
189 | 189 | " Can''t redirect. Aborting.", cr.getResponseCode())); |
190 | 190 | } else if (maxRedirects > 0) { |
| 191 | final URL oldUrl = url; |
191 | 192 | url = new URL(url, redirectLocation); |
192 | 193 | maxRedirects--; |
193 | 194 | logRequest(tr("Download redirected to ''{0}''", redirectLocation)); |
| 195 | // Fix JOSM #21935. |
| 196 | if (!Objects.equals(oldUrl.getHost(), this.url.getHost()) && this.getRequestHeader("Authorization") != null) { |
| 197 | logRequest(tr("Download redirected to different host (''{0}'' -> ''{1}''), removing authorization headers", |
| 198 | oldUrl.getHost(), url.getHost())); |
| 199 | this.headers.remove("Authorization"); |
| 200 | } |
194 | 201 | response = connect(); |
195 | 202 | successfulConnection = true; |
196 | 203 | return response; |