use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project uavstack by uavorg.
the class CECXFClient method configHttpConduit.
private void configHttpConduit(Object port) {
// 设置客户端的配置信息,超时等.
Client proxy = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
// 连接服务器超时时间
policy.setConnectionTimeout(this.connectTimeout);
// 等待服务器响应超时时间
policy.setReceiveTimeout(this.receiveTimeout);
conduit.setClient(policy);
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project jbossws-cxf by jbossws.
the class Helper method testGZIPServerSideOnlyInterceptorOnClient.
public boolean testGZIPServerSideOnlyInterceptorOnClient() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
HelloWorld port = getPort();
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = conduit.getClient();
// enable Accept gzip, otherwise the server will not try to reply using gzip
policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
// add interceptor for decoding gzip message
client.getInInterceptors().add(new GZIPEnforcingInInterceptor());
return ("foo".equals(port.echo("foo")));
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project jbossws-cxf by jbossws.
the class DefaultHTTPConduitFactoryWrapper method configureHTTPClientPolicy.
private void configureHTTPClientPolicy(HTTPConduit conduit) {
boolean set = false;
final Boolean allowChunking = (Boolean) configuration.get(Constants.CXF_CLIENT_ALLOW_CHUNKING);
set = set || (allowChunking != null);
final Integer chunkingThreshold = (Integer) configuration.get(Constants.CXF_CLIENT_CHUNKING_THRESHOLD);
set = set || (chunkingThreshold != null);
final Long connectionTimeout = (Long) configuration.get(Constants.CXF_CLIENT_CONNECTION_TIMEOUT);
set = set || (connectionTimeout != null);
final Long receiveTimeout = (Long) configuration.get(Constants.CXF_CLIENT_RECEIVE_TIMEOUT);
set = set || (receiveTimeout != null);
final String connection = (String) configuration.get(Constants.CXF_CLIENT_CONNECTION);
set = set || (connection != null);
if (set) {
HTTPClientPolicy httpClientPolicy = conduit.getClient();
if (httpClientPolicy == null) {
httpClientPolicy = new HTTPClientPolicy();
conduit.setClient(httpClientPolicy);
}
if (allowChunking != null) {
httpClientPolicy.setAllowChunking(allowChunking);
}
if (chunkingThreshold != null) {
httpClientPolicy.setChunkingThreshold(chunkingThreshold);
}
if (connectionTimeout != null) {
httpClientPolicy.setConnectionTimeout(connectionTimeout);
}
if (receiveTimeout != null) {
httpClientPolicy.setReceiveTimeout(receiveTimeout);
}
if (connection != null) {
httpClientPolicy.setConnection(ConnectionType.fromValue(connection));
}
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project jbossws-cxf by jbossws.
the class Helper method testFailureGZIPServerSideOnlyInterceptorOnClient.
public boolean testFailureGZIPServerSideOnlyInterceptorOnClient() throws Exception {
HelloWorld port = getPort();
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = conduit.getClient();
// enable Accept gzip, otherwise the server will not try to reply using gzip
policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
try {
port.echo("foo");
return false;
} catch (Exception e) {
// expected exception, as the client is not able to decode gzip message
return true;
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project maven-plugins by apache.
the class RestJiraDownloader method setupWebClient.
private WebClient setupWebClient(String jiraUrl) {
WebClient client = WebClient.create(jiraUrl);
ClientConfiguration clientConfiguration = WebClient.getConfig(client);
HTTPConduit http = clientConfiguration.getHttpConduit();
// MCHANGES-324 - Maintain the client session
clientConfiguration.getRequestContext().put(Message.MAINTAIN_SESSION, Boolean.TRUE);
if (getLog().isDebugEnabled()) {
clientConfiguration.getInInterceptors().add(new LoggingInInterceptor());
clientConfiguration.getOutInterceptors().add(new LoggingOutInterceptor());
}
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
// MCHANGES-341 Externalize JIRA server timeout values to the configuration section
getLog().debug("RestJiraDownloader: connectionTimeout: " + connectionTimeout);
httpClientPolicy.setConnectionTimeout(connectionTimeout);
httpClientPolicy.setAllowChunking(false);
getLog().debug("RestJiraDownloader: receiveTimout: " + receiveTimout);
httpClientPolicy.setReceiveTimeout(receiveTimout);
// MCHANGES-334 RestJiraDownloader doesn't honor proxy settings
getProxyInfo(jiraUrl);
if (proxyHost != null) {
getLog().debug("Using proxy: " + proxyHost + " at port " + proxyPort);
httpClientPolicy.setProxyServer(proxyHost);
httpClientPolicy.setProxyServerPort(proxyPort);
httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
if (proxyUser != null) {
ProxyAuthorizationPolicy proxyAuthorizationPolicy = new ProxyAuthorizationPolicy();
proxyAuthorizationPolicy.setAuthorizationType("Basic");
proxyAuthorizationPolicy.setUserName(proxyUser);
proxyAuthorizationPolicy.setPassword(proxyPass);
http.setProxyAuthorization(proxyAuthorizationPolicy);
}
}
if (webUser != null) {
AuthorizationPolicy authPolicy = new AuthorizationPolicy();
authPolicy.setAuthorizationType("Basic");
authPolicy.setUserName(webUser);
authPolicy.setPassword(webPassword);
http.setAuthorization(authPolicy);
}
http.setClient(httpClientPolicy);
return client;
}
Aggregations