Changeset 13872 in josm for trunk/src


Ignore:
Timestamp:
2018-05-30T19:04:15+02:00 (7 years ago)
Author:
wiktorn
Message:

Fix WMS_ENDPOINT headers.

  • Use custom headers when calling GetCapabilities on server
  • Pass custom headers and other imagery attributes after layer selection
  • if GetCapabilities document defines GetMap url, ensure that it ends with '?'

Closes: #16330

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r13839 r13872  
    167167        try {
    168168            CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT.equals(info.getImageryType()), "wms_endpoint imagery type expected");
    169             final WMSImagery wms = new WMSImagery(info.getUrl());
     169            final WMSImagery wms = new WMSImagery(info.getUrl(), info.getCustomHttpHeaders());
    170170
    171171            final WMSLayerTree tree = new WMSLayerTree();
     
    201201                    .map(LayerDetails::getName)
    202202                    .collect(Collectors.joining(", "));
    203             ImageryInfo ret = new ImageryInfo(info.getName() + selectedLayers,
    204                     url,
    205                     "wms",
    206                     info.getEulaAcceptanceRequired(),
    207                     info.getCookies());
    208 
     203            // Use full copy of original Imagery info to copy all attributes. Only overwrite what's different
     204            ImageryInfo ret = new ImageryInfo(info);
     205            ret.setUrl(url);
     206            ret.setImageryType(ImageryType.WMS);
     207            ret.setName(info.getName() + selectedLayers);
    209208            ret.setServerProjections(wms.getServerProjections(tree.getSelectedLayers()));
    210 
    211209            return ret;
    212210        } catch (MalformedURLException ex) {
  • trunk/src/org/openstreetmap/josm/data/imagery/WMSEndpointTileSource.java

    r13829 r13872  
    4343        CheckParameterUtil.ensure(info, "imageryType", x -> ImageryType.WMS_ENDPOINT.equals(x.getImageryType()));
    4444        try {
    45             wmsi = new WMSImagery(info.getUrl());
     45            wmsi = new WMSImagery(info.getUrl(), info.getCustomHttpHeaders());
    4646        } catch (IOException | WMSGetCapabilitiesException e) {
    4747            throw new IllegalArgumentException(e);
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r13829 r13872  
    432432                        // TODO should we handle also POST?
    433433                        if ("GET".equalsIgnoreCase(mode) && getMapUrl != null && !"".equals(getMapUrl)) {
    434                             this.getMapUrl = getMapUrl;
     434                            if (getMapUrl.endsWith("?")) {
     435                                this.getMapUrl = getMapUrl;
     436                            } else {
     437                                this.getMapUrl = getMapUrl + "?";
     438                            }
    435439                        }
    436440                    }
Note: See TracChangeset for help on using the changeset viewer.