- Timestamp:
- 2011-07-11T15:53:09+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
r4184 r4228 19 19 import java.text.NumberFormat; 20 20 import java.util.ArrayList; 21 import java.util.Map.Entry; 21 22 import java.util.Locale; 23 import java.util.Map; 24 import java.util.HashMap; 22 25 import java.util.regex.Matcher; 23 26 import java.util.regex.Pattern; … … 44 47 protected String baseURL; 45 48 private final boolean urlWithPatterns; 49 private Map<String, String> props = new HashMap<String, String>(); 46 50 47 51 public WMSGrabber(MapView mv, WMSLayer layer) { … … 50 54 /* URL containing placeholders? */ 51 55 urlWithPatterns = ImageryInfo.isUrlWithPatterns(baseURL); 56 if(layer.getInfo().getCookies() != null && !layer.getInfo().getCookies().equals("")) { 57 props.put("Cookie", layer.getInfo().getCookies()); 58 } 59 props.put("User-Agent", Main.pref.get("imagery.wms.user_agent", Version.getInstance().getAgentString())); 60 Pattern pattern = Pattern.compile("\\{header\\(([^,]+),([^}]+)\\)\\}"); 61 StringBuffer output = new StringBuffer(); 62 Matcher matcher = pattern.matcher(this.baseURL); 63 while (matcher.find()) { 64 props.put(matcher.group(1),matcher.group(2)); 65 matcher.appendReplacement(output, ""); 66 } 67 matcher.appendTail(output); 68 this.baseURL = output.toString(); 52 69 } 53 70 … … 211 228 212 229 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 213 if(layer.getInfo().getCookies() != null && !layer.getInfo().getCookies().equals("")) { 214 conn.setRequestProperty("Cookie", layer.getInfo().getCookies()); 215 } 216 conn.setRequestProperty("User-Agent", Main.pref.get("imagery.wms.user_agent", Version.getInstance().getAgentString())); 230 for(Entry<String, String> e : props.entrySet()) { 231 conn.setRequestProperty(e.getKey(), e.getValue()); 232 } 217 233 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15) * 1000); 218 234 conn.setReadTimeout(Main.pref.getInteger("socket.timeout.read", 30) * 1000);
Note:
See TracChangeset
for help on using the changeset viewer.