Ignore:
Timestamp:
2016-05-30T10:11:58+02:00 (8 years ago)
Author:
donvip
Message:

see #josm12878 - add robustness to cadastre plugin

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java

    r32060 r32205  
    105105     */
    106106    private void getCookie() throws IOException {
    107         boolean cookied = false;
     107        boolean sucess = false;
    108108        int retries = cRetriesGetCookie;
    109109        try {
    110110            searchFormURL = new URL(baseURL + "/scpc/accueil.do");
    111             while (cookied == false && retries > 0) {
     111            while (sucess == false && retries > 0) {
    112112                urlConn = (HttpURLConnection)searchFormURL.openConnection();
    113113                urlConn.setRequestProperty("Connection", "close");
     
    118118                    BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
    119119                    while(in.readLine() != null) {}  // read the buffer otherwise we sent POST too early
    120                     String headerName=null;
     120                    sucess = true;
     121                    String headerName;
    121122                    for (int i=1; (headerName = urlConn.getHeaderFieldKey(i))!=null; i++) {
    122                         if (headerName.equals("Set-Cookie")) {
     123                        if (Main.isDebugEnabled()) {
     124                            Main.debug(headerName + ": " + urlConn.getHeaderField(i));
     125                        }
     126                        if ("Set-Cookie".equals(headerName)) {
    123127                            cookie = urlConn.getHeaderField(i);
    124                             cookie = cookie.substring(0, cookie.indexOf(";"));
    125                             cookieTimestamp = new Date().getTime();
    126                             Main.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));
    127                             cookied = true;
    128                         }
     128                            if (cookie.isEmpty()) {
     129                                Main.warn("received empty cookie");
     130                                cookie = null;
     131                            } else {
     132                                cookie = cookie.substring(0, cookie.indexOf(';'));
     133                                cookieTimestamp = new Date().getTime();
     134                                Main.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));
     135                                break;
     136                            }
     137                        }
    129138                    }
    130139                } else {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java

    r32060 r32205  
    6161            Main.warn("removed a duplicated layer");
    6262        } catch (WMSException e) {
     63            Main.warn(e);
    6364            errorMessage = e.getMessage();
    6465            wmsLayer.grabber.getWmsInterface().resetCookie();
Note: See TracChangeset for help on using the changeset viewer.