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