mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 00:39:58 +00:00
HttpClient: Remove unused request encoding parameter.
This commit is contained in:
parent
349aee9aac
commit
e50098f092
5 changed files with 46 additions and 63 deletions
|
@ -261,9 +261,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
final CharSequence page;
|
final CharSequence page;
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
page = httpClient.get(HttpUrl.parse(uri.toString()), parameters.substring(1),
|
page = httpClient.get(HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", Charsets.UTF_8);
|
"application/x-www-form-urlencoded");
|
||||||
else
|
else
|
||||||
page = httpClient.get(HttpUrl.parse(uri.append(parameters).toString()), Charsets.UTF_8);
|
page = httpClient.get(HttpUrl.parse(uri.append(parameters).toString()));
|
||||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -402,9 +402,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -487,9 +487,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -588,9 +588,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -666,9 +666,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -924,9 +924,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -1633,9 +1633,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -1717,9 +1717,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpReferer);
|
"application/x-www-form-urlencoded", httpReferer);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null, httpReferer);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpReferer);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -2092,10 +2092,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpRefererTrip);
|
"application/x-www-form-urlencoded", httpRefererTrip);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null,
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpRefererTrip);
|
||||||
httpRefererTrip);
|
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -2124,10 +2123,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
if (httpPost)
|
if (httpPost)
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), parameters.substring(1),
|
||||||
"application/x-www-form-urlencoded", null, httpRefererTrip);
|
"application/x-www-form-urlencoded", httpRefererTrip);
|
||||||
else
|
else
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), null,
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.append(parameters).toString()), httpRefererTrip);
|
||||||
httpRefererTrip);
|
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -2153,7 +2151,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), null, httpRefererTrip);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), httpRefererTrip);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -2179,7 +2177,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), null, httpRefererTrip);
|
httpClient.getInputStream(callback, HttpUrl.parse(uri.toString()), httpRefererTrip);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,7 +471,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
private static final Pattern P_AJAX_GET_STOPS_ID = Pattern.compile(".*?@L=0*(\\d+)@.*?");
|
private static final Pattern P_AJAX_GET_STOPS_ID = Pattern.compile(".*?@L=0*(\\d+)@.*?");
|
||||||
|
|
||||||
protected final SuggestLocationsResult jsonGetStops(final String uri) throws IOException {
|
protected final SuggestLocationsResult jsonGetStops(final String uri) throws IOException {
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), jsonGetStopsEncoding);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri));
|
||||||
|
|
||||||
final Matcher mJson = P_AJAX_GET_STOPS_JSON.matcher(page);
|
final Matcher mJson = P_AJAX_GET_STOPS_JSON.matcher(page);
|
||||||
if (mJson.matches()) {
|
if (mJson.matches()) {
|
||||||
|
@ -846,7 +846,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final String uri = checkNotNull(mgateEndpoint);
|
final String uri = checkNotNull(mgateEndpoint);
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json", Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -911,7 +911,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final String uri = checkNotNull(mgateEndpoint);
|
final String uri = checkNotNull(mgateEndpoint);
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json", Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -1012,7 +1012,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
true);
|
true);
|
||||||
|
|
||||||
final String uri = checkNotNull(mgateEndpoint);
|
final String uri = checkNotNull(mgateEndpoint);
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json", Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -1104,7 +1104,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final String uri = checkNotNull(mgateEndpoint);
|
final String uri = checkNotNull(mgateEndpoint);
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json", Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri), request, "application/json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -1917,7 +1917,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, HttpUrl.parse(endpoint), request, "application/xml", null, null);
|
}, HttpUrl.parse(endpoint), request, "application/xml", null);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
@ -3078,7 +3078,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final NearbyLocationsResult jsonNearbyLocations(final String uri) throws IOException {
|
protected final NearbyLocationsResult jsonNearbyLocations(final String uri) throws IOException {
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), jsonNearbyLocationsEncoding);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
|
|
@ -199,7 +199,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
|
||||||
final StringBuilder uri = new StringBuilder(stopFinderEndpoint);
|
final StringBuilder uri = new StringBuilder(stopFinderEndpoint);
|
||||||
uri.append(parameters);
|
uri.append(parameters);
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
try {
|
try {
|
||||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -279,7 +279,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
|
||||||
final StringBuilder uri = new StringBuilder(stopFinderEndpoint);
|
final StringBuilder uri = new StringBuilder(stopFinderEndpoint);
|
||||||
uri.append(parameters);
|
uri.append(parameters);
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
try {
|
try {
|
||||||
final List<Location> stations = new ArrayList<Location>();
|
final List<Location> stations = new ArrayList<Location>();
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -317,7 +317,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
|
||||||
final StringBuilder uri = new StringBuilder(stopFinderEndpoint);
|
final StringBuilder uri = new StringBuilder(stopFinderEndpoint);
|
||||||
uri.append(parameters);
|
uri.append(parameters);
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
final StringBuilder uri = new StringBuilder(tripEndpoint);
|
final StringBuilder uri = new StringBuilder(tripEndpoint);
|
||||||
uri.append(parameters);
|
uri.append(parameters);
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
|
@ -379,7 +378,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
uri.append("&s=").append(Math.min(16, maxLocations)); // artificial server limit
|
uri.append("&s=").append(Math.min(16, maxLocations)); // artificial server limit
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final List<Location> locations = new ArrayList<Location>();
|
final List<Location> locations = new ArrayList<Location>();
|
||||||
|
@ -435,7 +434,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
uri.append("&t=");
|
uri.append("&t=");
|
||||||
appendDate(uri, time);
|
appendDate(uri, time);
|
||||||
}
|
}
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -526,7 +525,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
uri.append("?eID=tx_vrsinfo_his_info&i=").append(ParserUtils.urlEncode(stationId));
|
uri.append("?eID=tx_vrsinfo_his_info&i=").append(ParserUtils.urlEncode(stationId));
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONObject head = new JSONObject(page.toString());
|
final JSONObject head = new JSONObject(page.toString());
|
||||||
|
@ -585,7 +584,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
final String uri = API_BASE + "?eID=tx_vrsinfo_ass2_objects&sc=" + sc + "&ac=" + ac + "&pc=" + ac + "&t=sap&q="
|
final String uri = API_BASE + "?eID=tx_vrsinfo_ass2_objects&sc=" + sc + "&ac=" + ac + "&pc=" + ac + "&t=sap&q="
|
||||||
+ ParserUtils.urlEncode(new Location(LocationType.ANY, null, null, constraint.toString()).name);
|
+ ParserUtils.urlEncode(new Location(LocationType.ANY, null, null, constraint.toString()).name);
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||||
|
@ -703,7 +702,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
uri.append("p");
|
uri.append("p");
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()), Charsets.UTF_8);
|
final CharSequence page = httpClient.get(HttpUrl.parse(uri.toString()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final List<Trip> trips = new ArrayList<Trip>();
|
final List<Trip> trips = new ArrayList<Trip>();
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -44,8 +43,6 @@ import javax.net.ssl.X509TrustManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
|
|
||||||
import de.schildbach.pte.exception.BlockedException;
|
import de.schildbach.pte.exception.BlockedException;
|
||||||
import de.schildbach.pte.exception.InternalErrorException;
|
import de.schildbach.pte.exception.InternalErrorException;
|
||||||
import de.schildbach.pte.exception.NotFoundException;
|
import de.schildbach.pte.exception.NotFoundException;
|
||||||
|
@ -138,18 +135,11 @@ public final class HttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence get(final HttpUrl url) throws IOException {
|
public CharSequence get(final HttpUrl url) throws IOException {
|
||||||
return get(url, null);
|
return get(url, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence get(final HttpUrl url, final Charset requestEncoding) throws IOException {
|
public CharSequence get(final HttpUrl url, final String postRequest, final String requestContentType)
|
||||||
return get(url, null, null, requestEncoding);
|
throws IOException {
|
||||||
}
|
|
||||||
|
|
||||||
public CharSequence get(final HttpUrl url, final String postRequest, final String requestContentType,
|
|
||||||
Charset requestEncoding) throws IOException {
|
|
||||||
if (requestEncoding == null)
|
|
||||||
requestEncoding = Charsets.ISO_8859_1;
|
|
||||||
|
|
||||||
final StringBuilder buffer = new StringBuilder();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
final Callback callback = new Callback() {
|
final Callback callback = new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,7 +147,7 @@ public final class HttpClient {
|
||||||
buffer.append(body.string());
|
buffer.append(body.string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getInputStream(callback, url, postRequest, requestContentType, requestEncoding, null);
|
getInputStream(callback, url, postRequest, requestContentType, null);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,22 +156,18 @@ public final class HttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getInputStream(final Callback callback, final HttpUrl url) throws IOException {
|
public void getInputStream(final Callback callback, final HttpUrl url) throws IOException {
|
||||||
getInputStream(callback, url, null, null);
|
getInputStream(callback, url, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getInputStream(final Callback callback, final HttpUrl url, final Charset requestEncoding,
|
public void getInputStream(final Callback callback, final HttpUrl url, final String referer) throws IOException {
|
||||||
final String referer) throws IOException {
|
getInputStream(callback, url, null, null, referer);
|
||||||
getInputStream(callback, url, null, null, requestEncoding, referer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getInputStream(final Callback callback, final HttpUrl url, final String postRequest,
|
public void getInputStream(final Callback callback, final HttpUrl url, final String postRequest,
|
||||||
final String requestContentType, Charset requestEncoding, final String referer) throws IOException {
|
final String requestContentType, final String referer) throws IOException {
|
||||||
checkNotNull(callback);
|
checkNotNull(callback);
|
||||||
checkNotNull(url);
|
checkNotNull(url);
|
||||||
|
|
||||||
if (requestEncoding == null)
|
|
||||||
requestEncoding = Charsets.ISO_8859_1;
|
|
||||||
|
|
||||||
int tries = 3;
|
int tries = 3;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue