Package org.apache.commons.httpclient.params

Examples of org.apache.commons.httpclient.params.HttpParams


        setDefaultParams();
  }

    // Set default parameters as needed
    private static void setDefaultParams(){
        HttpParams params = DefaultHttpParams.getDefaultParams();
       
        // Process httpclient parameters file
        String file=JMeterUtils.getProperty("httpclient.parameters.file"); // $NON-NLS-1$
        if (file != null) {
            HttpClientDefaultParameters.load(file,params);
        }
       
        // If the pre-emptive parameter is undefined, then we cans set it as needed
        // otherwise we should do what the user requested.
        canSetPreEmptive =  params.getParameter(HTTP_AUTHENTICATION_PREEMPTIVE) == null;

        // Handle old-style JMeter properties
        // Default to HTTP version 1.1
        String ver=JMeterUtils.getPropDefault("httpclient.version","1.1"); // $NON-NLS-1$ $NON-NLS-2$
        try {
            params.setParameter(HttpMethodParams.PROTOCOL_VERSION, HttpVersion.parse("HTTP/"+ver));
        } catch (ProtocolException e) {
            log.warn("Problem setting protocol version "+e.getLocalizedMessage());
        }
        String to= JMeterUtils.getProperty("httpclient.timeout");
        if (to != null){
            params.setIntParameter(HttpMethodParams.SO_TIMEOUT, Integer.parseInt(to));
        }

        // This must be done last, as must not be overridden
        params.setParameter(HttpMethodParams.COOKIE_POLICY,CookiePolicy.IGNORE_COOKIES);
        // We do our own cookie handling
    }
View Full Code Here


   * @param authManager
   *            the <code>AuthManager</code> containing all the authorisations for
   *            this <code>UrlConfig</code>
   */
  void setConnectionAuthorization(HttpClient client, URL u, AuthManager authManager) {
    HttpParams params = client.getParams();
    if (authManager != null) {
            Authorization auth = authManager.getAuthForURL(u);
            if (auth != null) {
                    String username = auth.getUser();
                    String realm = auth.getRealm();
                    String domain = auth.getDomain();
                    if (log.isDebugEnabled()){
                        log.debug(username + " >  D="+ username + " D="+domain+" R="+realm);
                    }
          client.getState().setCredentials(
                            new AuthScope(u.getHost(),u.getPort(),
                                realm.length()==0 ? null : realm //"" is not the same as no realm
                                ,AuthScope.ANY_SCHEME),
                            // NT Includes other types of Credentials
                            new NTCredentials(
                  username,
                                    auth.getPass(),
                                    localHost,
                  domain
              ));
          // We have credentials - should we set pre-emptive authentication?
          if (canSetPreEmptive){
            log.debug("Setting Pre-emptive authentication");
            params.setBooleanParameter(HTTP_AUTHENTICATION_PREEMPTIVE, true);
          }
      }
            else
            {
                client.getState().clearCredentials();
                if (canSetPreEmptive){
                  params.setBooleanParameter(HTTP_AUTHENTICATION_PREEMPTIVE, false);
                }
            }
    }
        else
        {
View Full Code Here

        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...
    }
View Full Code Here

        }
    }

    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);
    }
View Full Code Here

    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\"");
View Full Code Here

    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\"");
View Full Code Here

    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\"");
View Full Code Here

            //expected
        }
    }

    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\"");
       
View Full Code Here

        assertEquals(authscheme, authstate.getAuthScheme());
        assertEquals("value", authscheme.getParameter("param"));
    }

    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\"");
       
View Full Code Here

    public void invoke(PartnerRoleMessageExchange odeMex) {
        if (log.isDebugEnabled()) log.debug("Preparing " + getClass().getSimpleName() + " invocation...");
        try {
            // note: don't make this map an instance attribute, so we always get the latest version
            final Map<String, String> properties = pconf.getEndpointProperties(endpointReference);
            final HttpParams params = Properties.HttpClient.translate(properties);

            // build the http method
            final HttpMethod method = httpMethodConverter.createHttpRequest(odeMex, params);

            // create a client
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.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.