com.sun.jersey.api.client.Client.handle()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中com.sun.jersey.api.client.Client.handle()方法的一些代码示例,展示了Client.handle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.handle()方法的具体详情如下:
包路径:com.sun.jersey.api.client.Client
类名称:Client
方法名:handle

Client.handle介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

private static Map<String,List<String>> runRequestAndGetHeaders( URI baseUri ) throws Exception
{
  URI uri = baseUri.resolve( "db/data/transaction/commit" );
  ClientRequest request = createClientRequest( uri );
  ClientResponse response = createClient().handle( request );
  assertEquals( 200, response.getStatus() );
  return response.getHeaders();
}

代码示例来源:origin: neo4j/neo4j

public Response request( String method, String uri )
{
  return new Response( CLIENT.handle( build().build( buildUri( uri ), method ) ) );
}

代码示例来源:origin: neo4j/neo4j

public Response request( String method, String uri, Object payload )
{
  if ( payload == null )
  {
    return request( method, uri );
  }
  String jsonPayload = payload instanceof RawPayload ? ((RawPayload) payload).get() : createJsonFrom(
      payload );
  ClientRequest.Builder lastBuilder = build().entity( jsonPayload, MediaType.APPLICATION_JSON_TYPE );
  return new Response( CLIENT.handle( lastBuilder.build( buildUri( uri ), method ) ) );
}

代码示例来源:origin: neo4j/neo4j

ClientResponse response = client.handle( request );
if ( response.hasEntity() && response.getStatus() != 204 )

代码示例来源:origin: FamilySearch/gedcomx-java

private DiscoveryState(ClientRequest request, Client client, FamilyTreeStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: FamilySearch/gedcomx-java

private FamilyTreePersonState(ClientRequest request, Client client, FamilyTreeStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: FamilySearch/gedcomx-java

private FamilySearchCollectionState(ClientRequest request, Client client, FamilySearchStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: FamilySearch/gedcomx-java

private FamilySearchPersonState(ClientRequest request, Client client, FamilySearchStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: FamilySearch/gedcomx-java

private FamilySearchOrdinancesState(ClientRequest request, com.sun.jersey.api.client.Client client, FamilyTreeStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: FamilySearch/gedcomx-java

private FamilySearchGenealogies(ClientRequest request, Client client, GenealogiesStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: FamilySearch/gedcomx-java

private FamilySearchNames(ClientRequest request, Client client, FamilySearchStateFactory stateFactory) {
 this(request, client.handle(request), null, stateFactory);
}

代码示例来源:origin: stackoverflow.com

Request request = new Request(Method.GET, "http://my/rest/api");

Client client = new Client(Protocol.HTTP);

Response response = client.handle(request);

//get response representation and process

代码示例来源:origin: stackoverflow.com

Client client = new Client(Protocol.HTTP);
Request request = new Request(Method.GET, resourceRef);
Response response = client.handle(request);

assert response.getStatus().getCode() == 200;
assert response.isEntityAvailable();
assert response.getEntity().getMediaType().equals(MediaType.TEXT_HTML);

// Representation.getText() empties the InputStream, so we need to store the text in a variable
String text = response.getEntity().getText();
assert text.contains("search string");
assert text.contains("another search string");

代码示例来源:origin: stackoverflow.com

@Test
public void test() {
  String url ="http://localhost:8190/project/user/status";
  Client client = new Client(Protocol.HTTP);
  ChallengeResponse challengeResponse = new ChallengeResponse(ChallengeScheme.HTTP_BASIC,"user", "f399b0a660f684b2c5a6b4c054f22d89");
  Request request = new Request(Method.GET, url);
  request.setChallengeResponse(challengeResponse);
  Response response = client.handle(request);
  System.out.println("request"+response.getStatus().getCode());
  System.out.println("request test::"+response.getEntityAsText());
}

代码示例来源:origin: FamilySearch/gedcomx-java

protected ClientResponse invoke(ClientRequest request, StateTransitionOption... options) {
 for (StateTransitionOption option : options) {
  option.apply(request);
 }
 return getClient().handle(request);
}

代码示例来源:origin: stackoverflow.com

Client client = new Client(Protocol.HTTP);
 Request r = new Request();
 r.setResourceRef("http://127.0.0.1:8182/sample");
 r.setMethod(Method.GET);
 r.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>(MediaType.TEXT_XML));
 client.handle(r).getEntity().write(System.out);

代码示例来源:origin: FamilySearch/gedcomx-java

public RecordState newRecordState(URI discoveryUri, Client client, String method) {
 ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method);
 if (Boolean.valueOf(System.getProperty(DONT_FOLLOW_REDIRECTS))) {
  request.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
 }
 return newRecordState(request, client.handle(request), null);
}

代码示例来源:origin: FamilySearch/gedcomx-java

public CollectionState newCollectionState(URI discoveryUri, Client client, String method) {
 ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method);
 if (Boolean.valueOf(System.getProperty(DONT_FOLLOW_REDIRECTS))) {
  request.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
 }
 return newCollectionState(request, client.handle(request), null);
}

代码示例来源:origin: FamilySearch/gedcomx-java

public PersonState newPersonState(URI discoveryUri, Client client, String method) {
 ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method);
 if (Boolean.valueOf(System.getProperty(ENABLE_JERSEY_LOGGING_ENV_NAME))) {     // handles null
  client.addFilter(new com.sun.jersey.api.client.filter.LoggingFilter());
 }
 return newPersonState(request, client.handle(request), null);
}

代码示例来源:origin: FamilySearch/gedcomx-java

/**
 * Create a new places state with the given URI
 *
 * @param discoveryUri the discovery URI for places
 * @param client the client that will use the new places state
 * @param method the HTTP method to call
 * @return a new places state created with with the given URI
 */
public FamilySearchPlaces newPlacesState(URI discoveryUri, Client client, String method) {
 ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method);
 return newPlacesState(request, client.handle(request), null);
}

相关文章