Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpClient


   
    java.net.URL u=new java.net.URL(url);
    String soapAction="";
    String request=new String(b);
       
    HttpClient httpClient = new HttpClient();
        PostMethod httpPostMethod = new PostMethod(u.toExternalForm());
        httpPostMethod.setRequestHeader("SOAPAction", "\"" + soapAction + "\"");
        httpPostMethod.setRequestHeader("Content-Type", "text/xml");
        httpPostMethod.setRequestEntity(new StringRequestEntity(request));
        httpClient.executeMethod(httpPostMethod);
        String result=httpPostMethod.getResponseBodyAsString();
   
    return(result);
  }
View Full Code Here


      return downloadWGA(monitor, getWGADownloadURL());
  }
 
   public TemporaryFile downloadWGA(IProgressMonitor monitor, String url) throws IllegalStateException, IOException, URISyntaxException {
        monitor.setTaskName("Downloading OpenWGA from '" + url + "'");                    
        HttpClient client = new DefaultHttpClient((IProxyService)_proxyServiceTracker.getService(), new URI(url));
        GetMethod get = new GetMethod(url);
    int result = client.executeMethod(get);
    if (result == HttpURLConnection.HTTP_OK) {
      long size = get.getResponseContentLength();               
            TemporaryFile temp = new TemporaryFile("wga.war", new ProgressMonitorInputStream(monitor, "Downloading OpenWGA ", size, get.getResponseBodyAsStream()), getStateLocation().toFile());
      return temp;
    } else {
View Full Code Here

    public void setFormat(OMOutputFormat format) {
        this.format = format;
    }

    protected HttpClient getHttpClient(MessageContext msgContext) {
        HttpClient httpClient;
        final ConfigurationContext configContext = msgContext.getConfigurationContext();
        synchronized (lock) {
            httpClient = (HttpClient) configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
            if (httpClient == null) {
                log.trace("Making new ConnectionManager");
                HttpConnectionManager connManager = new MultiThreadedHttpConnectionManager();

                // In case we need to set any params, do it here, but for now use defaults.
//                HttpConnectionManagerParams params = new HttpConnectionManagerParams();
//                params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 200);
//                etc...
//                connManager.setParams(params);

                httpClient = new HttpClient(connManager);
                HttpClientParams clientParams = new HttpClientParams();
                // Set the default timeout in case we have a connection pool starvation to 30sec
                clientParams.setConnectionManagerTimeout(30000);
                httpClient.setParams(clientParams);
                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
            }

            // Get the timeout values set in the runtime
            initializeTimeouts(msgContext, httpClient);
View Full Code Here

  private final static Log log = LogFactory.getLog(JRestClient.class);

  private HttpClient httpClient;

  public JRestClient() {
    this.httpClient = new HttpClient();
    this.httpClient.getParams().setParameter(
        "http.protocol.allow-circular-redirects", true);
  }
View Full Code Here

        ContinueHandler hdl = new ContinueHandler();
        HttpServer server = new HttpServer(hdl);
        server.start();


        HttpClient httpClient = new HttpClient();
        httpClient.getParams().setParameter("http.protocol.expect-continue", true);

        PostMethod meth = new PostMethod("http://localhost:" + server.getLocalPort() + "/test");
        meth.setRequestBody("OK");

        httpClient.executeMethod(meth);
       
        Assert.assertEquals(200, meth.getStatusCode());
        Assert.assertEquals("OK", meth.getResponseBodyAsString());
       
        meth.releaseConnection();
View Full Code Here

        throws Exception
    {
        // Use the HEAD method to probe the file.
        method = new HeadMethod();
        setupMethod(method);
        final HttpClient client = fileSystem.getClient();
        final int status = client.executeMethod(method);
        method.releaseConnection();
        if (status == HttpURLConnection.HTTP_OK)
        {
            return FileType.FILE;
        }
View Full Code Here

    /**
     * Creates a new connection to the server.
     */
    public static HttpClient createConnection(String hostname, int port, String username, String password, FileSystemOptions fileSystemOptions) throws FileSystemException
    {
        HttpClient client;
        try
        {
            client = new HttpClient(new MultiThreadedHttpConnectionManager());
            final HostConfiguration config = new HostConfiguration();
            config.setHost(hostname, port);

            if (fileSystemOptions != null)
            {
                String proxyHost = HttpFileSystemConfigBuilder.getInstance().getProxyHost(fileSystemOptions);
                int proxyPort = HttpFileSystemConfigBuilder.getInstance().getProxyPort(fileSystemOptions);

                if (proxyHost != null && proxyPort > 0)
                {
                    config.setProxy(proxyHost, proxyPort);
                }
            }

            client.setHostConfiguration(config);

            if (username != null)
            {
                final UsernamePasswordCredentials creds =
                    new UsernamePasswordCredentials(username, password);
                client.getState().setCredentials(null, hostname, creds);
            }

            client.executeMethod(new HeadMethod());
        }
        catch (final Exception exc)
        {
            throw new FileSystemException("vfs.provider.http/connect.error", new Object[]{hostname}, exc);
        }
View Full Code Here

        throws FileSystemException
    {
        // Create the file system
        final GenericFileName rootName = (GenericFileName) name;

        HttpClient httpClient = HttpClientFactory.createConnection(rootName.getHostName(),
            rootName.getPort(),
            rootName.getUserName(),
            rootName.getPassword(),
            fileSystemOptions);
View Full Code Here

    String response = null;
    int statusCode = 0;

    try
    {
      HttpClient client = new HttpClient();
      setAuthentication(client, method);
      statusCode = client.executeMethod(method);

      response = IOUtils.toString(method.getResponseBodyAsStream(),
          method.getResponseCharSet());

      method.releaseConnection();
View Full Code Here

    // No automatic handling of cookies, we handle sesame's session cookies
    // manually
    HttpClientParams clientParams = new HttpClientParams();
    clientParams.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);

    httpClient = new HttpClient(clientParams, manager);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.HttpClient

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.