本文整理了Java中com.sun.jersey.api.client.Client.getHeadHandler()
方法的一些代码示例,展示了Client.getHeadHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.getHeadHandler()
方法的具体详情如下:
包路径:com.sun.jersey.api.client.Client
类名称:Client
方法名:getHeadHandler
暂无
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void callStopCarteRestService() throws Exception {
WebResource status = mock( WebResource.class );
doReturn( "<serverstatus>" ).when( status ).get( String.class );
WebResource stop = mock( WebResource.class );
doReturn( "Shutting Down" ).when( stop ).get( String.class );
Client client = mock( Client.class );
doCallRealMethod().when( client ).addFilter( any( HTTPBasicAuthFilter.class ) );
doCallRealMethod().when( client ).getHeadHandler();
doReturn( status ).when( client ).resource( "http://localhost:8080/kettle/status/?xml=Y" );
doReturn( stop ).when( client ).resource( "http://localhost:8080/kettle/stopCarte" );
mockStatic( Client.class );
when( Client.create( any( ClientConfig.class ) ) ).thenReturn( client );
Carte.callStopCarteRestService( "localhost", "8080", "admin", "Encrypted 2be98afc86aa7f2e4bb18bd63c99dbdde" );
// the expected value is: "Basic <base64 encoded username:password>"
assertEquals( "Basic " + new String( Base64.getEncoder().encode( "admin:password".getBytes( "utf-8" ) ) ),
getInternalState( client.getHeadHandler(), "authentication" ) );
}
}
代码示例来源:origin: com.sun.jersey/jersey-bundle
@Override
public ClientResponse handle(final ClientRequest request) throws ClientHandlerException {
Map<String, Object> effectiveProperties =
new HashMap<String, Object>(properties);
effectiveProperties.put(Client.class.getName(), this);
effectiveProperties.putAll(request.getProperties());
request.setProperties(effectiveProperties);
final ClientResponse response = getHeadHandler().handle(request);
response.getProperties().put(Client.class.getName(), this);
return response;
}
代码示例来源:origin: jersey/jersey-1.x
@Override
public ClientResponse handle(final ClientRequest request) throws ClientHandlerException {
Map<String, Object> effectiveProperties =
new HashMap<String, Object>(properties);
effectiveProperties.put(Client.class.getName(), this);
effectiveProperties.putAll(request.getProperties());
request.setProperties(effectiveProperties);
final ClientResponse response = getHeadHandler().handle(request);
response.getProperties().put(Client.class.getName(), this);
return response;
}
代码示例来源:origin: com.emc.ecs/object-client
public S3EncryptionClient(S3Config s3Config, ClientHandler clientHandler, EncryptionConfig encryptionConfig) {
super(s3Config, clientHandler);
this.encryptionConfig = encryptionConfig;
// create an encode chain based on parameters
CodecChain encodeChain = encryptionConfig.isCompressionEnabled()
? new CodecChain(encryptionConfig.getCompressionSpec(), encryptionConfig.getEncryptionSpec())
: new CodecChain(encryptionConfig.getEncryptionSpec());
encodeChain.setProperties(encryptionConfig.getCodecProperties());
// insert codec filter into chain before the authorization filter
// as usual, Jersey makes this quite hard
// first, make a list of the filters
List<ClientFilter> filters = new ArrayList<ClientFilter>();
ClientHandler handler = client.getHeadHandler();
while (handler instanceof ClientFilter) {
ClientFilter filter = (ClientFilter) handler;
if (filter instanceof AuthorizationFilter) {
// insert codec filter before checksum filter
filters.add(new CodecFilter(encodeChain).withCodecProperties(encryptionConfig.getCodecProperties()));
}
filters.add(filter);
handler = filter.getNext();
}
// then re-create the filter list (must reverse the list because filters are inserted back to front)
Collections.reverse(filters);
client.removeAllFilters();
for (ClientFilter filter : filters) {
client.addFilter(filter);
}
}
内容来源于网络,如有侵权,请联系作者删除!