Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpClient.executeMethod()


    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


 
   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

        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

    {
        // 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

                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

    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

  private void callAndCompare(int jettyPort, int xSocketPort, String path) throws IOException {

    HttpClient httpClient = new HttpClient();

    GetMethod jettyMethod = new GetMethod("http://localhost:" + jettyPort + path);
    int jettyStatusCode = httpClient.executeMethod(jettyMethod);
    String jettyResponse = jettyMethod.getResponseBodyAsString().trim();
    jettyMethod.releaseConnection();


    GetMethod xSocketMethod = new GetMethod("http://localhost:" + xSocketPort + path);
View Full Code Here

    String jettyResponse = jettyMethod.getResponseBodyAsString().trim();
    jettyMethod.releaseConnection();


    GetMethod xSocketMethod = new GetMethod("http://localhost:" + xSocketPort + path);
    int xSocketStatusCode = httpClient.executeMethod(xSocketMethod);
    String xSocketResponse = xSocketMethod.getResponseBodyAsString().trim();
    xSocketMethod.releaseConnection();

    Assert.assertEquals(jettyStatusCode, xSocketStatusCode);
    Assert.assertEquals(jettyResponse, xSocketResponse);
View Full Code Here

  public static Integer detectMIMEType(String url) {
    try {
      HttpClient httpClient = new HttpClient();
      HeadMethod method = new HeadMethod(url);
      method.getParams().setIntParameter("http.socket.timeout",5000);
      int code = httpClient.executeMethod(method);
      if (code == 200) {
        Header h = method.getResponseHeader("Content-Type");
        if (h != null) {
          HeaderElement[] headElm = h.getElements();
          if(headElm != null & headElm.length > 0){
View Full Code Here

    hc = setProxySetttings(hClient, hc);

    GetMethod gMethod = new GetMethod(url.toString());
    gMethod.setRequestHeader("cache-control", "no-cache");
    try {
      int status = hClient.executeMethod(gMethod);
      if (status != HttpStatus.SC_OK) {
        // Check for redirection.
        if (status == HttpStatus.SC_MOVED_PERMANENTLY
            || status == HttpStatus.SC_MOVED_TEMPORARILY
            || status == HttpStatus.SC_SEE_OTHER
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.