• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpParams类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.httpclient.params.HttpParams的典型用法代码示例。如果您正苦于以下问题:Java HttpParams类的具体用法?Java HttpParams怎么用?Java HttpParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpParams类属于org.apache.commons.httpclient.params包,在下文中一共展示了HttpParams类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDefaultParams

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
@Override
public HttpParams getDefaultParams()
{
    if (httpParams == null)
    {
        synchronized (this)
        {
            if (httpParams == null)
            {
                httpParams = createParams();
            }
        }
    }
    
    return httpParams;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:17,代码来源:HttpClientFactory.java


示例2: getParameter

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
@Override
public Object getParameter(final String name)
{
    // See if the parameter has been explicitly defined
    Object param = null;
    paramLock.readLock().lock();
    try
    {
        param = this.parameters.get(name);
    }
    finally
    {
        paramLock.readLock().unlock();
    }
    if (param == null)
    {
        // If not, see if defaults are available
        HttpParams defaults = getDefaults();
        if (defaults != null)
        {
            // Return default parameter value
            param = defaults.getParameter(name);
        }
    }
    return param;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:27,代码来源:HttpClientFactory.java


示例3: main

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public static void main(String[] args) {
    
    // register the auth scheme
    AuthPolicy.registerAuthScheme(SecretAuthScheme.NAME, SecretAuthScheme.class);

    // include the scheme in the AuthPolicy.AUTH_SCHEME_PRIORITY preference,
    // this can be done on a per-client or per-method basis but we'll do it
    // globally for this example
    HttpParams params = DefaultHttpParams.getDefaultParams();        
    ArrayList schemes = new ArrayList();
    schemes.add(SecretAuthScheme.NAME);
    schemes.addAll((Collection) params.getParameter(AuthPolicy.AUTH_SCHEME_PRIORITY));
    params.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
    
    // now that our scheme has been registered we can execute methods against
    // servers that require "Secret" authentication... 
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:18,代码来源:CustomAuthenticationExample.java


示例4: testChallengeSelection

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public void testChallengeSelection() throws Exception {
    List authPrefs = new ArrayList(3);
    authPrefs.add(AuthPolicy.NTLM);
    authPrefs.add(AuthPolicy.DIGEST);
    authPrefs.add(AuthPolicy.BASIC);
    HttpParams httpparams = new DefaultHttpParams(); 
    httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("unknown", "unknown realm=\"whatever\"");
    map.put("basic", "basic realm=\"whatever\"");
    
    AuthScheme authscheme = processor.selectAuthScheme(map);
    assertTrue(authscheme instanceof BasicScheme);
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:18,代码来源:TestChallengeProcessor.java


示例5: testInvalidChallenge

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public void testInvalidChallenge() throws Exception {
    List authPrefs = new ArrayList(3);
    authPrefs.add("unsupported1");
    authPrefs.add("unsupported2");
    HttpParams httpparams = new DefaultHttpParams(); 
    httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("unsupported1", "unsupported1 realm=\"whatever\"");
    map.put("unsupported2", "unsupported2 realm=\"whatever\"");
    try {
        AuthScheme authscheme = processor.selectAuthScheme(map);
        fail("AuthChallengeException should have been thrown");
    } catch (AuthChallengeException e) {
        //ignore
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:20,代码来源:TestChallengeProcessor.java


示例6: testUnsupportedChallenge

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public void testUnsupportedChallenge() throws Exception {
    List authPrefs = new ArrayList(3);
    authPrefs.add(AuthPolicy.NTLM);
    authPrefs.add(AuthPolicy.BASIC);
    authPrefs.add(AuthPolicy.DIGEST);
    HttpParams httpparams = new DefaultHttpParams(); 
    httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("unsupported1", "unsupported1 realm=\"whatever\"");
    map.put("unsupported2", "unsupported2 realm=\"whatever\"");
    
    try {
        AuthScheme authscheme = processor.selectAuthScheme(map);
        fail("AuthChallengeException should have been thrown");
    } catch (AuthChallengeException e) {
        //expected
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:22,代码来源:TestChallengeProcessor.java


示例7: testInvalidChallengeProcessing

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public void testInvalidChallengeProcessing() throws Exception {
    HttpParams httpparams = new DefaultHttpParams(); 
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("basic", "basic realm=\"whatever\", param=\"value\"");
    
    AuthState authstate = new AuthState();
    
    AuthScheme authscheme = processor.processChallenge(authstate, map);
    assertTrue(authscheme instanceof BasicScheme);
    assertEquals("whatever", authscheme.getRealm());
    assertEquals(authscheme, authstate.getAuthScheme());
    assertEquals("value", authscheme.getParameter("param"));

    Map map2 = new HashMap(); 
    map2.put("ntlm", "NTLM");
    try {
        // Basic authentication scheme expected
        authscheme = processor.processChallenge(authstate, map2);
        fail("AuthenticationException should have been thrown");
    } catch (AuthenticationException e) {
        //expected
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:26,代码来源:TestChallengeProcessor.java


示例8: setParameter

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public static void setParameter(HttpParams params, String paramName, String paramValue) {
	Class<?> paramType = getParameterType(paramName);
	if (paramType.equals(Boolean.class)) {
		params.setBooleanParameter(paramName, Boolean.parseBoolean(paramValue));
	} else if (paramType.equals(Integer.class)) {
		params.setIntParameter(paramName, Integer.parseInt(paramValue));
	} else if (paramType.equals(Long.class)) {
		params.setLongParameter(paramName, Long.parseLong(paramValue));
	} else if (paramType.equals(Double.class)) {
		params.setDoubleParameter(paramName, Double.parseDouble(paramValue));
	} else if (paramType.equals(String.class)) {
		params.setParameter(paramName, paramValue);
	} else if (paramType.equals(Class.class)) {
		try {
			Class<?> configuredClass = Class.forName(paramValue, true, ClassLoaderUtils.getDefaultClassLoader());
			params.setParameter(paramName, configuredClass);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException("Could not locate the class needed to configure the HttpClient.", e);
		}
	} else {
		throw new RuntimeException("Attempted to configure an HttpClient parameter '" + paramName + "' " +
				"of a type not supported through Workflow configuration: " + paramType.getName());
	}
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:25,代码来源:HttpClientHelper.java


示例9: configureDefaultHttpClientParams

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
protected void configureDefaultHttpClientParams(HttpParams params) {
	params.setParameter(HttpClientParams.CONNECTION_MANAGER_CLASS, MultiThreadedHttpConnectionManager.class);
	params.setParameter(HttpMethodParams.COOKIE_POLICY, CookiePolicy.RFC_2109);
	params.setLongParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 10000);
	Map<HostConfiguration, Integer> maxHostConnectionsMap = new HashMap<HostConfiguration, Integer>();
	maxHostConnectionsMap.put(HostConfiguration.ANY_HOST_CONFIGURATION, new Integer(20));
	params.setParameter(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, maxHostConnectionsMap);
	params.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 20);
	params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 10000);
	params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 2*60*1000);
	

	boolean retrySocketException = new Boolean(ConfigContext.getCurrentContextConfig().getProperty(RETRY_SOCKET_EXCEPTION_PROPERTY));
	if (retrySocketException) {
	    LOG.info("Installing custom HTTP retry handler to retry requests in face of SocketExceptions");
	    params.setParameter(HttpMethodParams.RETRY_HANDLER, new CustomHttpMethodRetryHandler());
	}

	
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:21,代码来源:HttpInvokerConnector.java


示例10: AuthChallengeProcessor

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
/**
 * Creates an authentication challenge processor with the given {@link HttpParams HTTP 
 * parameters}
 * 
 * @param params the {@link HttpParams HTTP parameters} used by this processor
 */
public AuthChallengeProcessor(final HttpParams params) {
    super();
    if (params == null) {
        throw new IllegalArgumentException("Parameter collection may not be null");
    }
    this.params = params;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:14,代码来源:AuthChallengeProcessor.java


示例11: promptForCredentials

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
private Credentials promptForCredentials(
    final AuthScheme authScheme,
    final HttpParams params, 
    final AuthScope authscope)
{
    LOG.debug("Credentials required");
    Credentials creds = null;
    CredentialsProvider credProvider = 
        (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER);
    if (credProvider != null) {
        try {
            creds = credProvider.getCredentials(
                authScheme, authscope.getHost(), authscope.getPort(), false);
        } catch (CredentialsNotAvailableException e) {
            LOG.warn(e.getMessage());
        }
        if (creds != null) {
            this.state.setCredentials(authscope, creds);
            if (LOG.isDebugEnabled()) {
                LOG.debug(authscope + " new credentials given");
            }
        }
    } else {
        LOG.debug("Credentials provider not available");
    }
    return creds;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:28,代码来源:HttpMethodDirector.java


示例12: promptForProxyCredentials

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
private Credentials promptForProxyCredentials(
    final AuthScheme authScheme,
    final HttpParams params,
    final AuthScope authscope) 
{
    LOG.debug("Proxy credentials required");
    Credentials creds = null;
    CredentialsProvider credProvider = 
        (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER);
    if (credProvider != null) {
        try {
            creds = credProvider.getCredentials(
                authScheme, authscope.getHost(), authscope.getPort(), true);
        } catch (CredentialsNotAvailableException e) {
            LOG.warn(e.getMessage());
        }
        if (creds != null) {
            this.state.setProxyCredentials(authscope, creds);
            if (LOG.isDebugEnabled()) {
                LOG.debug(authscope + " new credentials given");
            }
        }
    } else {
        LOG.debug("Proxy credentials provider not available");
    }
    return creds;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:28,代码来源:HttpMethodDirector.java


示例13: checkDate

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
private void checkDate(String date) throws Exception {
    Header header = new Header("Set-Cookie", "custno=12345;Expires='"+date+"';");
    HttpParams params = new DefaultHttpParamsFactory().getDefaultParams();
    CookieSpec cookiespec = new CookieSpecBase();
    cookiespec.setValidDateFormats(
            (Collection)params.getParameter(HttpMethodParams.DATE_PATTERNS));
    cookieParse(cookiespec, "localhost", 80, "/", false, header);
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:9,代码来源:TestCookieCompatibilitySpec.java


示例14: testChallengeProcessing

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public void testChallengeProcessing() throws Exception {
    HttpParams httpparams = new DefaultHttpParams(); 
    AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);

    Map map = new HashMap(); 
    map.put("basic", "basic realm=\"whatever\", param=\"value\"");
    
    AuthState authstate = new AuthState();
    
    AuthScheme authscheme = processor.processChallenge(authstate, map);
    assertTrue(authscheme instanceof BasicScheme);
    assertEquals("whatever", authscheme.getRealm());
    assertEquals(authscheme, authstate.getAuthScheme());
    assertEquals("value", authscheme.getParameter("param"));
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:16,代码来源:TestChallengeProcessor.java


示例15: main

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public static void main(String[] args) {
    
    // register the auth scheme
    AuthPolicy.registerAuthScheme("Negotiate", NegotiateScheme.class);

    // include the scheme in the AuthPolicy.AUTH_SCHEME_PRIORITY preference
    ArrayList schemes = new ArrayList();
    schemes.add("Negotiate");

    HttpParams params = DefaultHttpParams.getDefaultParams();        
    params.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
    
    // now that our scheme has been registered we can execute methods against
    // servers that require "Negotiate" authentication... 
    HttpClient client = new HttpClient();
    
    // The Negotiate scheme uses JAAS as credential provider but the
    // httpclient api require us to supply cred anyway.
    // a work around is to provide an empty set of creds.
    Credentials use_jaas_creds = new Credentials() {};
    client.getState().setCredentials(
        new AuthScope(null, -1, null),
        use_jaas_creds);
    GetMethod httpget = new GetMethod(args[0]);

    try {
        client.executeMethod(httpget);
        //System.out.println(httpget.getStatusLine());
        //System.out.println(httpget.getResponseBodyAsString());
    } catch (Exception e) {
        e.printStackTrace();            
    } finally {
        // release any connection resources used by the method
        httpget.releaseConnection();
    }            
    
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:38,代码来源:CustomAuthenticationNegotiateExample.java


示例16: executeMethod

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
/**
     * Requests the received method.
     *
     * Executes the method through the inherited HttpClient.executedMethod(method).
     *
     * @param method                HTTP method request.
     */
    @Override
    public int executeMethod(HttpMethod method) throws IOException {
        try {
            // Update User Agent
            HttpParams params = method.getParams();
            String userAgent = OwnCloudClientManagerFactory.getUserAgent();
            params.setParameter(HttpMethodParams.USER_AGENT, userAgent);

            Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " +
                    method.getName() + " " + method.getPath());

//	        logCookiesAtRequest(method.getRequestHeaders(), "before");
//	        logCookiesAtState("before");
            method.setFollowRedirects(false);

            int status = super.executeMethod(method);

            if (mFollowRedirects) {
                status = followRedirection(method).getLastStatus();
            }

//	        logCookiesAtRequest(method.getRequestHeaders(), "after");
//	        logCookiesAtState("after");
//	        logSetCookiesAtResponse(method.getResponseHeaders());

            return status;

        } catch (IOException e) {
            //Log_OC.d(TAG + " #" + mInstanceNumber, "Exception occurred", e);
            throw e;
        }
    }
 
开发者ID:PicFrame,项目名称:picframe,代码行数:40,代码来源:OwnCloudClient.java


示例17: NonBlockingHttpParams

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public NonBlockingHttpParams(HttpParams defaults)
{
    super(defaults);
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:5,代码来源:HttpClientFactory.java


示例18: setConnectionParams

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
public void setConnectionParams(HttpParams httpParams) {
    this.connectionParams = httpParams;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:4,代码来源:ProxyClient.java


示例19: getParams

import org.apache.commons.httpclient.params.HttpParams; //导入依赖的package包/类
/**
 * @return
 */
public HttpParams getParams() {
    return this.params;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:7,代码来源:HttpMethodDirector.java



注:本文中的org.apache.commons.httpclient.params.HttpParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IDLTypesUtil类代码示例发布时间:2022-05-22
下一篇:
Java Time类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap