Examples of HttpRequestBase


Examples of org.apache.http.client.methods.HttpRequestBase

    assertEquals(HttpStatusCodes.TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
  }

  @Test
  public void testMergeServiceDocumentRedirect() throws Exception {
    final HttpRequestBase httpMethod = createRedirectRequest(HttpMerge.class);
    final HttpResponse response = getHttpClient().execute(httpMethod);
    assertEquals(HttpStatusCodes.TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    assertEquals(HttpStatusCodes.TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
  }

  @Test
  public void testPatchServiceDocumentRedirect() throws Exception {
    final HttpRequestBase httpMethod = createRedirectRequest(HttpPatch.class);
    final HttpResponse response = getHttpClient().execute(httpMethod);
    assertEquals(HttpStatusCodes.TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    assertEquals(HttpStatusCodes.TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
  }

  @Test
  public void testSomethingUnsupportedServiceDocumentRedirect() throws Exception {
    final HttpRequestBase httpMethod = createRedirectRequest(HttpSomethingUnsupported.class);
    final HttpResponse response = getHttpClient().execute(httpMethod);
    assertEquals(HttpStatusCodes.NOT_IMPLEMENTED.getStatusCode(), response.getStatusLine().getStatusCode());
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

  private HttpRequestBase createRedirectRequest(final Class<? extends HttpRequestBase> clazz) throws Exception {
    String endpoint = getEndpoint().toASCIIString();
    endpoint = endpoint.substring(0, endpoint.length() - 1);

    final HttpRequestBase httpMethod = clazz.newInstance();
    httpMethod.setURI(URI.create(endpoint));

    final HttpParams params = new BasicHttpParams();
    params.setParameter("http.protocol.handle-redirects", false);
    httpMethod.setParams(params);
    return httpMethod;
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

      final ODataHttpMethod httpMethod, final String uri,
      final String additionalHeader, final String additionalHeaderValue,
      final String requestBody, final String requestContentType,
      final HttpStatusCodes expectedStatusCode) throws Exception {

    HttpRequestBase request =
        httpMethod == ODataHttpMethod.GET ? new HttpGet() :
            httpMethod == ODataHttpMethod.DELETE ? new HttpDelete() :
                httpMethod == ODataHttpMethod.POST ? new HttpPost() :
                    httpMethod == ODataHttpMethod.PUT ? new HttpPut() : new HttpPatch();
    request.setURI(URI.create(getEndpoint() + uri));
    if (additionalHeader != null) {
      request.addHeader(additionalHeader, additionalHeaderValue);
    }
    if (requestBody != null) {
      ((HttpEntityEnclosingRequest) request).setEntity(new StringEntity(requestBody));
      request.setHeader(HttpHeaders.CONTENT_TYPE, requestContentType);
    }

    final HttpResponse response = getHttpClient().execute(request);

    assertNotNull(response);
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    }

    APILoginResult result = new APILoginResult();
       
    try {
      HttpRequestBase method = getInitializedPostMethod(loginURL,loginParams);
      ExecuteAPILoginThread t = new ExecuteAPILoginThread(client, method, result);
      try {
        t.start();
        t.join();

        handleException(t.getException());
      } catch (ManifoldCFException e) {
        t.interrupt();
        throw e;
      } catch (ServiceInterruption e) {
        t.interrupt();
        throw e;
      } catch (IOException e) {
        t.interrupt();
        throw e;
      } catch (HttpException e) {
  t.interrupt();
  throw e;
      } catch (InterruptedException e) {
        t.interrupt();
        // We need the caller to abandon any connections left around, so rethrow in a way that forces them to process the event properly.
        throw e;
      }
     
      if (result.result)
        return true;
     
      // Grab the token from the first call
      token = t.getToken();
      if (token == null)
      {
        // We don't need a token, we just couldn't log in
        Logging.connectors.debug("WIKI API login error: '" + result.reason + "'");
        throw new ManifoldCFException("WIKI API login error: " + result.reason, null, ManifoldCFException.REPOSITORY_CONNECTION_ERROR);
      }
     
    } catch (InterruptedException e) {
      throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
    } catch (ManifoldCFException e) {
      throw e;
    } catch (java.net.SocketTimeoutException e) {
      long currentTime = System.currentTimeMillis();
      throw new ServiceInterruption("Login timed out reading from the Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L * 60000L, -1, false);
    } catch (java.net.SocketException e) {
      long currentTime = System.currentTimeMillis();
      throw new ServiceInterruption("Login received a socket error reading from Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L * 60000L, -1, false);
    } catch (ConnectTimeoutException e) {
      long currentTime = System.currentTimeMillis();
      throw new ServiceInterruption("Login connection timed out reading from Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L * 60000L, -1, false);
    } catch (InterruptedIOException e) {
      throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
    } catch (IOException e) {
      throw new ManifoldCFException("Login had an IO failure: " + e.getMessage(), e);
    } catch (HttpException e) {
      throw new ManifoldCFException("Login had an Http exception: "+e.getMessage(), e);
    }

    // First request is finished.  Fire off the second one.
   
    loginParams.put("lgtoken", token);
   
    try {
      HttpRequestBase method = getInitializedPostMethod(loginURL,loginParams);
      ExecuteTokenAPILoginThread t = new ExecuteTokenAPILoginThread(httpClient, method, result);
      try {
        t.start();
        t.join();

View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    while (true)
    {
      HttpClient client = httpClient;
      try
      {
  HttpRequestBase executeMethod = getInitializedGetMethod(getCheckURL());
        ExecuteCheckThread t = new ExecuteCheckThread(client,executeMethod);
        try
        {
          t.start();
          t.join();
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    boolean loginAttempted = false;
    while (true)
    {
      try
      {
  HttpRequestBase executeMethod = getInitializedGetMethod(getListPagesURL(startPageTitle,namespace,prefix));
        XThreadStringBuffer pageBuffer = new XThreadStringBuffer();
        ExecuteListPagesThread t = new ExecuteListPagesThread(httpClient,executeMethod,pageBuffer,startPageTitle);
        try
        {
          t.start();
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    boolean loginAttempted = false;
    while (true)
    {
      try
      {
  HttpRequestBase executeMethod = getInitializedGetMethod(getGetDocURLsURL(documentIdentifiers));
        ExecuteGetDocURLsThread t = new ExecuteGetDocURLsThread(httpClient,executeMethod,urls);
        try
        {
          t.start();
          t.join();
View Full Code Here

Examples of org.apache.http.client.methods.HttpRequestBase

    boolean loginAttempted = false;
    while (true)
    {
      try
      {
  HttpRequestBase executeMethod = getInitializedGetMethod(getGetTimestampURL(documentIdentifiers));
        ExecuteGetTimestampThread t = new ExecuteGetTimestampThread(httpClient,executeMethod,versions);
        try
        {
          t.start();
          t.join();
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.