add http request options
This commit is contained in:
parent
85a4bbe125
commit
0b82df4c21
@ -85,19 +85,15 @@ public class LwHttp implements HttpEngine {
|
||||
|
||||
REQUEST_GET_START = ("GET " + path).getBytes();
|
||||
|
||||
String addRequest = "";
|
||||
if (tileSource.getRequestHeader() != null) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (Entry<String, String> l : tileSource.getRequestHeader().entrySet())
|
||||
sb.append('\n').append(l.getKey()).append(": ").append(l.getValue());
|
||||
addRequest = sb.toString();
|
||||
}
|
||||
StringBuilder opt = new StringBuilder();
|
||||
for (Entry<String, String> l : tileSource.getRequestHeader().entrySet())
|
||||
opt.append('\n').append(l.getKey()).append(": ").append(l.getValue());
|
||||
|
||||
REQUEST_GET_END = (" HTTP/1.1" +
|
||||
"\nUser-Agent: vtm/0.5.9" +
|
||||
"\nHost: " + host +
|
||||
"\nConnection: Keep-Alive" +
|
||||
addRequest +
|
||||
opt.toString() +
|
||||
"\n\n").getBytes();
|
||||
|
||||
mHost = host;
|
||||
|
@ -22,6 +22,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.utils.IOUtils;
|
||||
@ -65,6 +66,9 @@ public class OkHttpEngine implements HttpEngine {
|
||||
URL url = new URL(mTileSource.getTileUrl(tile));
|
||||
HttpURLConnection conn = mClient.open(url);
|
||||
|
||||
for (Entry<String, String> opt : mTileSource.getRequestHeader().entrySet())
|
||||
conn.addRequestProperty(opt.getKey(), opt.getValue());
|
||||
|
||||
inputStream = conn.getInputStream();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ package org.oscim.tiling.source;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.core.Tile;
|
||||
@ -27,12 +28,11 @@ import org.oscim.tiling.source.LwHttp.LwHttpFactory;
|
||||
public abstract class UrlTileSource extends TileSource {
|
||||
|
||||
public final static TileUrlFormatter URL_FORMATTER = new DefaultTileUrlFormatter();
|
||||
|
||||
private final URL mUrl;
|
||||
private final String[] mTilePath;
|
||||
|
||||
private HttpEngine.Factory mHttpFactory;
|
||||
private Map<String, String> mRequestHeaders;
|
||||
private Map<String, String> mRequestHeaders = Collections.emptyMap();
|
||||
private TileUrlFormatter mTileUrlFormatter = URL_FORMATTER;
|
||||
|
||||
public interface TileUrlFormatter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user