Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpGet.reset()


            }
            catch (Exception e) {
                message = DataSourceRT.getExceptionMessage(e);
            }
            finally {
                request.reset();
            }

            if (retries <= 0)
                throw new TranslatableException(message);
            retries--;
View Full Code Here


                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (request != null) {
                    request.reset();
                }
            }
        }
    }
View Full Code Here

           
            HttpResponse response = this.httpClient.execute(get);
           
            //Expect a 4xx response
            int status = response.getStatusLine().getStatusCode();
            get.reset();
            if (status >= 400 && status < 500) {
                //OK
                LOGGER.info("Request failed as expected with HTTP Code " + status);
            } else {
                throw new ValidationError("Query Request with multiple queries did not fail with 4xx status code as expected, got HTTP status code " + status);
View Full Code Here

    assertNotNull(response1);

    URI serviceRoot1 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
    assertEquals(uri1.getHost(), serviceRoot1.getHost());

    get1.reset();

    URI uri2 =
        new URI(uri1.getScheme(), uri1.getUserInfo(), "127.0.0.1", uri1.getPort(), uri1.getPath(), uri1.getQuery(),
            uri1.getFragment());
View Full Code Here

      assertNotNull(response1);

      URI serviceRoot1 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
      assertEquals(uri.getHost(), serviceRoot1.getHost());

      get1.reset();

      HttpGet get2 = new HttpGet(uri);
      get2.addHeader("Host", "bla:123");
      HttpResponse response2 = getHttpClient().execute(get2);
      assertNotNull(response2);
View Full Code Here

    getMethod.addHeader(userAgentHeader);
    try {
      Assert.assertEquals(httpClient.execute(getMethod, localcontext).getStatusLine().getStatusCode(), 200);
    }
    finally {
      getMethod.reset();
    }

    Cookie sessionCookie = this.getSessionCookie(httpClient.getCookieStore().getCookies());
    Assert.assertNotNull("Session Cookie not set", sessionCookie);
View Full Code Here

    getMethod = new HttpGet(url);
    try {
      Assert.assertEquals(httpClient.execute(getMethod).getStatusLine().getStatusCode(), 200);
    }
    finally {
      getMethod.reset();
    }

    // do logout
    HttpGet logoutGetMethod = new HttpGet(logoutUrl);
    try {
View Full Code Here

      final HttpResponse response = httpClient.execute(logoutGetMethod);
      Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
      Assert.assertEquals("OK", EntityUtils.toString(response.getEntity()));
    }
    finally {
      logoutGetMethod.reset();
    }

    // set cookie again
    httpClient.getCookieStore().clear(); // remove cookies
    httpClient.getCredentialsProvider().clear(); // remove auth
View Full Code Here

    try {
      final HttpResponse response = httpClient.execute(failedGetMethod);
      Assert.assertEquals(response.getStatusLine().getStatusCode(), 401);
    }
    finally {
      failedGetMethod.reset();
    }
  }

  private Cookie getSessionCookie(Collection<Cookie> cookies) {
    for (Cookie cookie : cookies) {
View Full Code Here

            for (Entry<String, String> header : headers.entrySet()) {
                getRequest.addHeader(header.getKey(), header.getValue());
            }

            response = httpClient.execute(getRequest);
            getRequest.reset();

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
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.