Examples of executeMethod()


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

  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

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

    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

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

  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

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

    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

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

          Header locationHeader = gMethod
              .getResponseHeader("location");
          if (locationHeader != null) {
            redirectLocation = locationHeader.getValue();
            gMethod = new GetMethod(redirectLocation);
            status = hClient.executeMethod(gMethod);
            if (status != HttpStatus.SC_OK) {
              throw new NetworkException(gMethod.getStatusLine()
                  .getReasonPhrase());
            }
          } else {
View Full Code Here

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

                        AuthScope.ANY_REALM),
                    getCredentials(feed));

            gMethod = new GetMethod(url.toString());
            gMethod.setDoAuthentication(true);
            status = hClient.executeMethod(gMethod);
            if (status != HttpStatus.SC_OK) {
              throw new NetworkException(gMethod.getStatusLine()
                  .getReasonPhrase());
            }
          } else {
View Full Code Here

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

      GetMethod gMethod = new GetMethod(url.toString());
      gMethod.setFollowRedirects(false);
      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

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

                .getResponseHeader("location");
            if (locationHeader != null) {
              redirectLocation = locationHeader.getValue();

              gMethod = new GetMethod(redirectLocation);
              status = hClient.executeMethod(gMethod);
              if (status != HttpStatus.SC_OK) {
                throw new NetworkException(gMethod
                    .getStatusLine().getReasonPhrase());
              }
            } else {
View Full Code Here

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

                      AuthScope.ANY_PORT,
                      AuthScope.ANY_REALM),
                  getCredentials(pFeed));
              gMethod = new GetMethod(url.toString());
              gMethod.setDoAuthentication(true);
              status = hClient.executeMethod(gMethod);
              if (status != HttpStatus.SC_OK) {
                throw new NetworkException(gMethod
                    .getStatusLine().getReasonPhrase());
              }
            } else {
View Full Code Here

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

    hc = setProxySetttings(hClient, hc);
    HeadMethod hMethod = null;
    try {
      hMethod = new HeadMethod(url.toString());
      hMethod.setRequestHeader("cache-control", "no-cache");
      int status = hClient.executeMethod(hMethod);

      if (status != HttpStatus.SC_OK) {
        // Check for redirection.
        if (status == HttpStatus.SC_MOVED_PERMANENTLY
            || status == HttpStatus.SC_MOVED_TEMPORARILY
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.