use of org.apache.http.params.HttpParams in project qksms by moezbhatti.
the class HttpUtils method createHttpClient.
private static AndroidHttpClient createHttpClient(Context context) {
String userAgent = MmsConfig.getUserAgent();
AndroidHttpClient client = AndroidHttpClient.newInstance(userAgent, context);
HttpParams params = client.getParams();
HttpProtocolParams.setContentCharset(params, "UTF-8");
// set the socket timeout
int soTimeout = MmsConfig.getHttpSocketTimeout();
if (LOCAL_LOGV)
Log.d(TAG, "[HttpUtils] createHttpClient w/ socket timeout " + soTimeout + " ms, " + ", UA=" + userAgent);
HttpConnectionParams.setSoTimeout(params, soTimeout);
return client;
}
use of org.apache.http.params.HttpParams in project ignition by mttkay.
the class IgnitedHttp method updateProxySettings.
/**
* Updates the underlying HTTP client's proxy settings with what the user has entered in the APN
* settings. This will be called automatically if {@link #listenForConnectivityChanges(Context)}
* has been called. <b>This requires the {@link Manifest.permission#ACCESS_NETWORK_STATE}
* permission</b>.
*
* @param context
* the current context
*/
public void updateProxySettings(Context context) {
if (context == null) {
return;
}
HttpParams httpParams = httpClient.getParams();
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo nwInfo = connectivity.getActiveNetworkInfo();
if (nwInfo == null) {
return;
}
Log.i(LOG_TAG, nwInfo.toString());
if (nwInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
String proxyHost = Proxy.getHost(context);
if (proxyHost == null) {
proxyHost = Proxy.getDefaultHost();
}
int proxyPort = Proxy.getPort(context);
if (proxyPort == -1) {
proxyPort = Proxy.getDefaultPort();
}
if (proxyHost != null && proxyPort > -1) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} else {
httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null);
}
} else {
httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null);
}
}
use of org.apache.http.params.HttpParams in project custom-cert-https by nelenkov.
the class MainActivity method createHttpClient.
private HttpClient createHttpClient(SocketFactory socketFactory) {
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);
ConnPerRoute connPerRoute = new ConnPerRouteBean(MAX_CONN_PER_ROUTE);
ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
ConnManagerParams.setMaxTotalConnections(params, MAX_CONNECTIONS);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
SocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
if (socketFactory != null) {
sslSocketFactory = socketFactory;
}
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
return new DefaultHttpClient(cm, params);
}
use of org.apache.http.params.HttpParams in project openhab1-addons by openhab.
the class StreamClientImpl method getRequestParams.
protected HttpParams getRequestParams(StreamRequestMessage requestMessage) {
HttpParams localParams = new BasicHttpParams();
localParams.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, requestMessage.getOperation().getHttpMinorVersion() == 0 ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1);
// DefaultHttpClient adds HOST header automatically in its default processor
// Let's add the user-agent header on every request
HttpProtocolParams.setUserAgent(localParams, getConfiguration().getUserAgentValue(requestMessage.getUdaMajorVersion(), requestMessage.getUdaMinorVersion()));
return new DefaultedHttpParams(localParams, globalParams);
}
use of org.apache.http.params.HttpParams in project mobile-android by photo.
the class ApiBase method execute.
/**
* Execute a request to the API.
*
* @param request request to perform
* @param baseUrl the base server url
* @param consumer the oauth consumer key to sign request
* @param listener Progress Listener with callback on progress
* @param connectionTimeout the connection and socket timeout
* @return the response from the API
* @throws ClientProtocolException
* @throws IOException
*/
public ApiResponse execute(ApiRequest request, String baseUrl, OAuthConsumer consumer, ProgressListener listener, int connectionTimeout) throws ClientProtocolException, IOException {
// PoolingClientConnectionManager();
HttpParams params = new BasicHttpParams();
// set params for connection...
HttpConnectionParams.setStaleCheckingEnabled(params, false);
HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);
HttpConnectionParams.setSoTimeout(params, connectionTimeout);
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
DefaultHttpClient httpClient = new DefaultHttpClient(params);
HttpUriRequest httpRequest = createHttpRequest(request, baseUrl, listener);
httpRequest.getParams().setBooleanParameter("http.protocol.expect-continue", false);
httpRequest.setHeader("User-Agent", "android");
httpRequest.setHeader("source", "android");
if (consumer != null) {
try {
consumer.sign(httpRequest);
} catch (Exception e) {
GuiUtils.noAlertError(TAG, "Error signing request", e);
}
} else {
TrackerUtils.trackBackgroundEvent("not_signed_request", baseUrl + request.getPath());
}
return new ApiResponse(baseUrl + request.getPath(), httpClient.execute(httpRequest));
}
Aggregations