Ignore:
Timestamp:
2016-03-05T21:36:33+01:00 (9 years ago)
Author:
simon04
Message:

see #12584 - Attempt to obtain the session cookie via CookieManager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r9913 r9935  
    77import java.io.IOException;
    88import java.lang.reflect.Field;
     9import java.net.CookieHandler;
    910import java.net.HttpURLConnection;
     11import java.net.URISyntaxException;
    1012import java.net.URL;
    1113import java.nio.charset.StandardCharsets;
     14import java.util.Collections;
    1215import java.util.HashMap;
    1316import java.util.Iterator;
     
    199202    }
    200203
    201     protected SessionId extractOsmSession() {
    202         List<String> setCookies = connection.getResponse().getHeaderFields().get("Set-Cookie");
     204    protected SessionId extractOsmSession() throws IOException, URISyntaxException {
     205        // response headers might not contain the cookie, see #12584
     206        final List<String> setCookies = CookieHandler.getDefault()
     207                .get(connection.getURL().toURI(), Collections.<String, List<String>>emptyMap())
     208                .get("Cookie");
    203209        if (setCookies == null) {
    204210            Main.warn("No 'Set-Cookie' in response header!");
     
    267273                        tr("OSM website did not return a session cookie in response to ''{0}'',", url.toString()));
    268274            return sessionId;
    269         } catch (IOException e) {
     275        } catch (IOException | URISyntaxException e) {
    270276            throw new OsmOAuthAuthorizationException(e);
    271277        } finally {
Note: See TracChangeset for help on using the changeset viewer.