本文整理了Java中org.apache.commons.httpclient.HttpClient.setState()
方法的一些代码示例,展示了HttpClient.setState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.setState()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.HttpClient
类名称:HttpClient
方法名:setState
[英]Assigns HttpState for the HttpClient.
[中]
代码示例来源:origin: elastic/elasticsearch-hadoop
private void completeAuth(Object[] authSettings) {
if (authSettings[1] != null) {
client.setState((HttpState) authSettings[1]);
client.getParams().setAuthenticationPreemptive(true);
}
}
代码示例来源:origin: geotools/geotools
if (state == null) {
state = new HttpState();
client.setState(state);
代码示例来源:origin: geotools/geotools
if (state == null) {
state = new HttpState();
client.setState(state);
代码示例来源:origin: tracee/tracee
@Override
public synchronized void setState(HttpState state) {
delegate.setState(state);
}
代码示例来源:origin: sakaiproject/sakai
/**
* Resets the http client state between requests,
* this is not necessarily required but might be a good idea
*/
public void resetState() {
if (initialHttpState != null) {
httpClient.setState(initialHttpState);
} else {
httpClient.setState( new HttpState() );
}
}
/**
代码示例来源:origin: org.elasticsearch/elasticsearch-hadoop
private void completeAuth(Object[] authSettings) {
if (authSettings[1] != null) {
client.setState((HttpState) authSettings[1]);
client.getParams().setAuthenticationPreemptive(true);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch-hadoop-mr
private void completeAuth(Object[] authSettings) {
if (authSettings[1] != null) {
client.setState((HttpState) authSettings[1]);
client.getParams().setAuthenticationPreemptive(true);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch-spark-13
private void completeAuth(Object[] authSettings) {
if (authSettings[1] != null) {
client.setState((HttpState) authSettings[1]);
client.getParams().setAuthenticationPreemptive(true);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch-spark
private void completeAuth(Object[] authSettings) {
if (authSettings[1] != null) {
client.setState((HttpState) authSettings[1]);
client.getParams().setAuthenticationPreemptive(true);
}
}
代码示例来源:origin: net.adamcin.granite/granite-client-packman
private void setState(HttpState state) {
getClient().setState(state);
}
代码示例来源:origin: org.apache.excalibur.components/excalibur-sourceresolve
/**
* Initializes this {@link HTTPClientSource} instance.
*
* @exception Exception if an error occurs
*/
public void initialize() throws Exception
{
this.m_client = new HttpClient();
if ( this.m_proxyHost != null && this.m_proxyPort != -1 )
{
this.m_client.getHostConfiguration().setProxy( this.m_proxyHost, this.m_proxyPort );
}
if (this.m_httpState != null)
{
this.m_client.setState(this.m_httpState);
}
this.m_dataValid = false;
}
代码示例来源:origin: org.zaproxy/zap
private void checkState() {
if (param.isHttpStateEnabled()) {
client.setState(param.getHttpState());
clientViaProxy.setState(param.getHttpState());
setClientsCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
} else {
setClientsCookiePolicy(CookiePolicy.IGNORE_COOKIES);
}
}
代码示例来源:origin: slide/slide-webdavlib
/**
* Discover and refresh lock tokens for a specific owner.
*
* @param owner the owner who's locks are to be discovered.
* @exception HttpException
* @exception IOException
*/
public void discoverOwnLocks(String owner)
throws HttpException, IOException {
setClient();
WebdavState state = (WebdavState) client.getState();
state = discoverLock(owner, httpURL.getPath(), state);
client.setState(state);
}
代码示例来源:origin: org.nuiton/maven-helper-plugin
RestSession(RestClientConfiguration configuration) {
showRequest = configuration.isVerbose();
this.configuration = configuration;
client = new HttpClient();
HostConfiguration hostConfiguration = new HostConfiguration();
// Anomalie #917: Can not specify port in rest api (tchemit 2010-10-07)
int port = configuration.getRestUrl().getPort();
if (port == -1) {
// no port set
hostConfiguration.setHost(configuration.getRestUrl().getHost());
} else {
// a specific port is asked
hostConfiguration.setHost(configuration.getRestUrl().getHost(), port);
}
// set encoding (will then encode parameters fine)
client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, configuration.getEncoding());
client.setHostConfiguration(hostConfiguration);
client.setState(new HttpState());
}
代码示例来源:origin: org.tinygroup/org.tinygroup.httpvisit
public void init() {
client = new HttpClient(new MultiThreadedHttpConnectionManager());
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
client.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
client.setState(httpState);
if (authPrefs != null) {
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
}
if (proxyHost != null) {
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
if (proxyUserPassword != null) {
httpState.setProxyCredentials(new AuthScope(proxyHost, proxyPort), proxyUserPassword);
}
}
}
代码示例来源:origin: org.tinygroup/httpvisit
public void init() {
client = new HttpClient(new MultiThreadedHttpConnectionManager());
client.getHttpConnectionManager().getParams()
.setConnectionTimeout(timeout);
client.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
client.setState(httpState);
if (authPrefs != null) {
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
authPrefs);
}
if (proxyHost != null) {
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
if (proxyUserPassword != null) {
httpState.setProxyCredentials(new AuthScope(proxyHost,
proxyPort), proxyUserPassword);
}
}
}
代码示例来源:origin: com.googlecode.fighting-layout-bugs/fighting-layout-bugs
public MockBrowser(HttpClient httpClient) {
_httpClient = httpClient;
HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
_threadPool = Executors.newFixedThreadPool(10);
} else {
LOG.warn("The configured HttpClient does not use a MultiThreadedHttpConnectionManager, will only use 1 thread (instead of 10) for downloading CSS files and checking image URLs ...");
_threadPool = Executors.newFixedThreadPool(1);
}
HttpState httpState = new HttpState();
WebDriver driver = _webPage.getDriver();
for (org.openqa.selenium.Cookie cookie : driver.manage().getCookies()) {
httpState.addCookie(new Cookie(cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getExpiry(), cookie.isSecure()));
}
_httpClient.setState(httpState);
}
代码示例来源:origin: slide/slide-webdavlib
/**
* Discover and refresh lock tokens.
*
* @exception HttpException
* @exception IOException
*/
public void discoverOwnLocks()
throws HttpException, IOException {
setClient();
String owner = (httpURL.getUser() != null) ?
httpURL.getUser() : defaultOwner;
WebdavState state = (WebdavState) client.getState();
state = discoverLock(owner, httpURL.getPath(), state);
client.setState(state);
}
代码示例来源:origin: CyberSource/cybersource-sdk-java
/**
* This method is useful in Client environment where Firewall is set to prevent accessing the external services.
* Proxy settings are required in such scenarios.
* @param httpClient
*/
private void setProxy(HttpClient httpClient) {
if (mc.getProxyHost() != null) {
httpClient.getHostConfiguration().setProxy(
mc.getProxyHost(), mc.getProxyPort());
if (mc.getProxyUser() != null) {
List<String> authPrefs = new ArrayList<String>();
authPrefs.add(AuthPolicy.BASIC);
httpClient.getParams().setParameter(
AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
HttpState state = new HttpState();
state.setProxyCredentials(
AuthScope.ANY,
new UsernamePasswordCredentials(
mc.getProxyUser(), mc.getProxyPassword()));
httpClient.setState(state);
}
}
}
代码示例来源:origin: org.mule.transports/mule-transport-http
protected HttpClient doClientConnect() throws Exception
{
HttpState state = new HttpState();
if (getProxyUsername() != null)
{
Credentials credentials;
if (isProxyNtlmAuthentication())
{
credentials = new NTCredentials(getProxyUsername(), getProxyPassword(), getProxyHostname(), "");
}
else
{
credentials = new UsernamePasswordCredentials(getProxyUsername(), getProxyPassword());
}
AuthScope authscope = new AuthScope(getProxyHostname(), getProxyPort());
state.setProxyCredentials(authscope, credentials);
}
HttpClient client = new HttpClient();
client.setState(state);
client.setHttpConnectionManager(getClientConnectionManager());
return client;
}
内容来源于网络,如有侵权,请联系作者删除!