Package org.apache.http.params

Examples of org.apache.http.params.HttpParams


   * @param aconfig
   * @param cookies
   */
  public void init(Site _site) {
    //设置HTTP参数
    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.USER_AGENT, config.getUserAgentString());
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, config.getSocketTimeout());
    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, config.getConnectionTimeout());
   
    HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params);
    paramsBean.setVersion(HttpVersion.HTTP_1_1);
    paramsBean.setContentCharset("UTF-8");
    paramsBean.setUseExpectContinue(false);
View Full Code Here


            throw new RuntimeException("Unable to get resource", e);
        }
    }
   
    private void initHttpClient() {
        HttpParams parameters = new BasicHttpParams();
        HttpProtocolParams.setVersion(parameters, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(parameters, HTTP.DEFAULT_CONTENT_CHARSET);
        // set the User-Agent to a common User-Agent because currently
        // the default httpclient User-Agent doesn't work with dailymile
        HttpProtocolParams.setUserAgent(parameters,
View Full Code Here

    HttpClient(DownloadSettings settings) {
        this.settings = settings;
        httpClient = new DefaultHttpClient();
        interceptor = new DownloaderInterceptor();
        httpClient.addRequestInterceptor(interceptor);
        HttpParams params = httpClient.getParams();
        params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
        //params.setParameter(CoreProtocolPNames.USER_AGENT, settings.getHttpUserAgent());
        String proxys = settings.getHttpProxyServer();
        int port = settings.getHttpProxyPort();
        if (proxys != null && !proxys.equals("")) {
            HttpHost proxy;
            if (port > 0) {
                proxy = new HttpHost(settings.getHttpProxyServer(), settings.getHttpProxyPort());
            } else {
                proxy = new HttpHost(settings.getHttpProxyServer());
            }
            params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        }
        //TODO add support for SOCKS

    }
View Full Code Here

            httpClient.getConnectionManager().shutdown();
        }
    }

    private HttpClient composeHttpClient(HttpActionDefinition definition) {
        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, definition.getConnectionTimeoutMs());
        HttpConnectionParams.setSoTimeout(httpParameters, 0);

        DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
View Full Code Here

        throws HttpException, IOException {

        HttpRoute route = roureq.getRoute();
        RequestWrapper request = roureq.getRequest();

        HttpParams params = request.getParams();
        if (HttpClientParams.isRedirecting(params) &&
                this.redirectStrategy.isRedirected(request, response, context)) {

            if (redirectCount >= maxRedirects) {
                throw new RedirectException("Maximum redirects ("
View Full Code Here

    protected ClientConnectionManager createClientConnectionManager() {
        SchemeRegistry registry = SchemeRegistryFactory.createDefault();

        ClientConnectionManager connManager = null;
        HttpParams params = getParams();

        ClientConnectionManagerFactory factory = null;

        String className = (String) params.getParameter(
                ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
View Full Code Here

    @Test
    public void testUsesBackendsHttpParams() {
        expect(mockBackend.getParams()).andReturn(params);
        replayMocks();
        HttpParams result = impl.getParams();
        verifyMocks();
        Assert.assertSame(params, result);
    }
View Full Code Here

        if (!uri.startsWith("http4:") && !uri.startsWith("https4:")) {
            addressUri = remaining;
        }
        Map<String, Object> httpClientParameters = new HashMap<String, Object>(parameters);
        // http client can be configured from URI options
        HttpParams clientParams = configureHttpParams(parameters);
        // validate that we could resolve all httpClient. parameters as this component is lenient
        validateParameters(uri, parameters, "httpClient.");
       
        // TODO cmueller: remove the "httpBindingRef" look up in Camel 3.0
        HttpBinding httpBinding = resolveAndRemoveReferenceParameter(parameters, "httpBindingRef", HttpBinding.class);
View Full Code Here

        return answer;
    }

    protected HttpParams configureHttpParams(Map<String, Object> parameters) throws Exception {
        HttpParams clientParams = new BasicHttpParams();

        AuthParamBean authParamBean = new AuthParamBean(clientParams);
        IntrospectionSupport.setProperties(authParamBean, parameters, "httpClient.");

        ClientParamBean clientParamBean = new ClientParamBean(clientParams);
View Full Code Here

    public static void main(String[] args) throws Exception {
        if (args.length < 1) {
            System.err.println("Please specify document root directory");
            System.exit(1);
        }
        HttpParams params = new BasicHttpParams(null);
        params
            .setIntParameter(HttpConnectionParams.SO_TIMEOUT, 5000)
            .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false)
            .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true)
            .setIntParameter(HttpNIOParams.CONTENT_BUFFER_SIZE, 10240)
View Full Code Here

TOP

Related Classes of org.apache.http.params.HttpParams

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.