Ticket #21935: 21935.patch

File 21935.patch, 1.4 KB (added by taylor.smock, 3 years ago)

Initial (minimal) patch

  • src/org/openstreetmap/josm/tools/HttpClient.java

    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 {  
    188188                    throw new IOException(tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." +
    189189                            " Can''t redirect. Aborting.", cr.getResponseCode()));
    190190                } else if (maxRedirects > 0) {
     191                    final URL oldUrl = url;
    191192                    url = new URL(url, redirectLocation);
    192193                    maxRedirects--;
    193194                    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                    }
    194201                    response = connect();
    195202                    successfulConnection = true;
    196203                    return response;