org.apache.http.client.methods.HttpGet#reset()源码实例Demo

下面列出了org.apache.http.client.methods.HttpGet#reset() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: rdf4j   文件: RDF4JProtocolSession.java
public void getRepositoryList(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException,
		RepositoryException, UnauthorizedException, QueryInterruptedException {
	checkServerURL();

	HttpGet method = applyAdditionalHeaders(new HttpGet(Protocol.getRepositoriesLocation(serverURL)));

	try {
		getTupleQueryResult(method, handler);
	} catch (MalformedQueryException e) {
		// This shouldn't happen as no queries are involved
		logger.warn("Server reported unexpected malfored query error", e);
		throw new RepositoryException(e.getMessage(), e);
	} finally {
		method.reset();
	}
}
 
源代码2 项目: olingo-odata2   文件: CxfCacheUriInfoIssueTest.java
@Test
public void checkContextForDifferentHostNamesRequests() throws ClientProtocolException, IOException, ODataException,
    URISyntaxException {
  URI uri1 = URI.create(getEndpoint().toString() + "$metadata");

  HttpGet get1 = new HttpGet(uri1);
  HttpResponse response1 = getHttpClient().execute(get1);
  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());

  HttpGet get2 = new HttpGet(uri2);
  HttpResponse response2 = getHttpClient().execute(get2);
  assertNotNull(response2);

  URI serviceRoot2 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
  assertEquals(uri2.getHost(), serviceRoot2.getHost());
}
 
源代码3 项目: cloud-odata-java   文件: TestIssue105.java
@Test
public void checkContextForDifferentHostNamesRequests() throws ClientProtocolException, IOException, ODataException, URISyntaxException {
  URI uri1 = URI.create(getEndpoint().toString() + "$metadata");

  HttpGet get1 = new HttpGet(uri1);
  HttpResponse response1 = getHttpClient().execute(get1);
  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());

  HttpGet get2 = new HttpGet(uri2);
  HttpResponse response2 = getHttpClient().execute(get2);
  assertNotNull(response2);

  URI serviceRoot2 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
  assertEquals(uri2.getHost(), serviceRoot2.getHost());
}
 
源代码4 项目: rdf4j   文件: RDF4JProtocolSession.java
public void getNamespaces(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException,
		RepositoryException, UnauthorizedException, QueryInterruptedException {
	checkRepositoryURL();

	HttpGet method = applyAdditionalHeaders(new HttpGet(Protocol.getNamespacesLocation(getQueryURL())));

	try {
		getTupleQueryResult(method, handler);
	} catch (MalformedQueryException e) {
		logger.warn("Server reported unexpected malfored query error", e);
		throw new RepositoryException(e.getMessage(), e);
	} finally {
		method.reset();
	}
}
 
源代码5 项目: rdf4j   文件: RDF4JProtocolSession.java
public void getContextIDs(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException,
		RepositoryException, UnauthorizedException, QueryInterruptedException {
	checkRepositoryURL();

	HttpGet method = applyAdditionalHeaders(new HttpGet(Protocol.getContextsLocation(getQueryURL())));

	try {
		getTupleQueryResult(method, handler);
	} catch (MalformedQueryException e) {
		logger.warn("Server reported unexpected malfored query error", e);
		throw new RepositoryException(e.getMessage(), e);
	} finally {
		method.reset();
	}
}
 
源代码6 项目: olingo-odata2   文件: CxfCacheUriInfoIssueTest.java
@Test
public void checkContextForDifferentWithHostHeader() throws ClientProtocolException, IOException,
    ODataException, URISyntaxException {
  try {
    FitStaticServiceFactory.bindService("123", getService());

    // 1st request: cache uri
    URI uri = URI.create(getEndpoint().toString() + "$metadata");
    HttpGet get1 = new HttpGet(uri);
    HttpResponse response1 = getHttpClient().execute(get1);
    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);

    URI serviceRoot2 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
    assertEquals("bla", serviceRoot2.getHost());
    assertEquals(123, serviceRoot2.getPort());

    URI requestUri = getService().getProcessor().getContext().getPathInfo().getRequestUri();
    assertEquals("bla", requestUri.getHost());
    assertEquals(123, requestUri.getPort());

  } finally {
    FitStaticServiceFactory.unbindService("123");
  }
}
 
源代码7 项目: Thunder   文件: AbstractStockServiceImpl.java
@Override
public List<Stock> execute(String[] codes, StockType stockType, boolean simple) {
    barrier.reset();

    InterfaceType interfaceType = getInterfaceType();
    if (interfaceType == InterfaceType.SINA) {
        if (stockType == StockType.ZHULI || stockType == StockType.PANKOU) {
            return null;
        }
    }

    String url = getUrl(codes, stockType);
    if (url == null) {
        return null;
    }

    String id = RandomUtil.uuidRandom();

    AbstractStockCallback callback = getCallback();
    callback.setCodes(codes);
    callback.setStockType(stockType);
    callback.setInterfaceType(interfaceType);
    callback.setSimple(simple);
    callback.setId(id);
    callback.setCacheMap(cacheMap);
    callback.setBarrier(barrier);

    HttpGet httpGet = new HttpGet(url);

    CloseableHttpAsyncClient httpAsyncClient = clientExecutor.getClient();
    httpAsyncClient.execute(httpGet, callback);
    try {
        barrier.await();
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    } finally {
        httpGet.reset();
    }

    List<Stock> stock = cacheMap.get(id);
    cacheMap.remove(id);

    return stock;
}