From a98ddca1714a1a7f451d80dcaba781b82be9334a Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Mon, 24 Feb 2014 16:29:40 +0100 Subject: [PATCH] add LwHttp constructor with additional request header items --- vtm/src/org/oscim/tiling/source/LwHttp.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vtm/src/org/oscim/tiling/source/LwHttp.java b/vtm/src/org/oscim/tiling/source/LwHttp.java index 6322a821..228f7ac4 100644 --- a/vtm/src/org/oscim/tiling/source/LwHttp.java +++ b/vtm/src/org/oscim/tiling/source/LwHttp.java @@ -24,6 +24,8 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; import java.net.URL; +import java.util.Map; +import java.util.Map.Entry; import org.oscim.core.Tile; import org.oscim.utils.ArrayUtils; @@ -74,6 +76,10 @@ public class LwHttp { * Base url for tiles */ public LwHttp(URL url) { + this(url, null); + } + + public LwHttp(URL url, Map header) { int port = url.getPort(); if (port < 0) @@ -85,10 +91,19 @@ public class LwHttp { REQUEST_GET_START = ("GET " + path).getBytes(); + String addRequest = ""; + if (header != null) { + StringBuffer sb = new StringBuffer(); + for (Entry l : header.entrySet()) + sb.append('\n').append(l.getKey()).append(": ").append(l.getValue()); + addRequest = sb.toString(); + } + REQUEST_GET_END = (" HTTP/1.1" + "\nUser-Agent: vtm/0.5.9" + "\nHost: " + host + "\nConnection: Keep-Alive" + + addRequest + "\n\n").getBytes(); mHost = host;