Add user-agent
This commit is contained in:
parent
af8d3db5b5
commit
0028c3a11d
4 changed files with 12 additions and 2 deletions
|
@ -74,7 +74,7 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
|
||||||
dbbug = new OsmBugsDbHelper(this);
|
dbbug = new OsmBugsDbHelper(this);
|
||||||
|
|
||||||
remotepoi = new OpenstreetmapRemoteUtil(this, this.getWindow().getDecorView());
|
remotepoi = new OpenstreetmapRemoteUtil(this, this.getWindow().getDecorView());
|
||||||
remotebug = new OsmBugsRemoteUtil();
|
remotebug = new OsmBugsRemoteUtil(getMyApplication());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@ public class OpenstreetmapRemoteUtil extends AbstractOpenstreetmapUtil {
|
||||||
|
|
||||||
connection.setConnectTimeout(15000);
|
connection.setConnectTimeout(15000);
|
||||||
connection.setRequestMethod(requestMethod);
|
connection.setRequestMethod(requestMethod);
|
||||||
|
connection.setRequestProperty("User-Agent", Version.getFullVersion(ctx)); //$NON-NLS-1$
|
||||||
StringBuilder responseBody = new StringBuilder();
|
StringBuilder responseBody = new StringBuilder();
|
||||||
if (doAuthenticate) {
|
if (doAuthenticate) {
|
||||||
String token = settings.USER_NAME.get() + ":" + settings.USER_PASSWORD.get(); //$NON-NLS-1$
|
String token = settings.USER_NAME.get() + ":" + settings.USER_PASSWORD.get(); //$NON-NLS-1$
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
public OsmBugsLayer(MapActivity activity){
|
public OsmBugsLayer(MapActivity activity){
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
local = new OsmBugsLocalUtil(activity);
|
local = new OsmBugsLocalUtil(activity);
|
||||||
remote = new OsmBugsRemoteUtil();
|
remote = new OsmBugsRemoteUtil(activity.getMyApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmBugsUtil getOsmbugsUtil(OpenStreetBug bug) {
|
public OsmBugsUtil getOsmbugsUtil(OpenStreetBug bug) {
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.Version;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -17,6 +19,12 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
||||||
|
|
||||||
private final static String SITE_API = "http://openstreetbugs.schokokeks.org/api/0.1/"; //$NON-NLS-1$
|
private final static String SITE_API = "http://openstreetbugs.schokokeks.org/api/0.1/"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
public OsmBugsRemoteUtil(OsmandApplication app) {
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createNewBug(double latitude, double longitude, String text, String authorName){
|
public boolean createNewBug(double latitude, double longitude, String text, String authorName){
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
|
@ -58,6 +66,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
||||||
log.debug("Action " + debugAction + " " + urlStr); //$NON-NLS-1$ //$NON-NLS-2$
|
log.debug("Action " + debugAction + " " + urlStr); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
URL url = new URL(urlStr);
|
URL url = new URL(urlStr);
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
|
connection.setRequestProperty("User-Agent", Version.getFullVersion(app)); //$NON-NLS-1$
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
while(reader.readLine() != null){
|
while(reader.readLine() != null){
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue