method.getParams().getCredentialCharset());
/** * Applies connection parameters specified for a given method * * @param method HTTP method * * @throws IOException if an I/O occurs setting connection parameters */ private void applyConnectionParams(final HttpMethod method) throws IOException { int timeout = 0; // see if a timeout is given for this method Object param = method.getParams().getParameter(HttpMethodParams.SO_TIMEOUT); if (param == null) { // if not, use the default value param = this.conn.getParams().getParameter(HttpConnectionParams.SO_TIMEOUT); } if (param != null) { timeout = ((Integer)param).intValue(); } this.conn.setSocketTimeout(timeout); }
host = conn.getProxyHost(); } else { host = method.getParams().getVirtualHost(); if (host == null) { host = conn.getHost();
/** * Reads and stores the Trailer headers. * @throws IOException If an IO problem occurs */ private void parseTrailerHeaders() throws IOException { Header[] footers = null; try { String charset = "US-ASCII"; if (this.method != null) { charset = this.method.getParams().getHttpElementCharset(); } footers = HttpParser.parseHeaders(in, charset); } catch(HttpException e) { LOG.error("Error parsing trailer headers", e); IOException ioe = new IOException(e.getMessage()); ExceptionUtil.initCause(ioe, e); throw ioe; } if (this.method != null) { for (int i = 0; i < footers.length; i++) { this.method.addResponseFooter(footers[i]); } } }
return false; String host = method.getParams().getVirtualHost(); if (host == null) { host = conn.getHost(); authscheme, method.getParams(), authscope); if (credentials == null) { if (LOG.isInfoEnabled()) { if (credentials == null) { credentials = promptForCredentials( authscheme, method.getParams(), authscope);
String charset = getParameter("charset"); if (charset == null) { getParameters().put("charset", method.getParams().getCredentialCharset());
method.getParams().getCredentialCharset()); if (auth != null) { String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP;
(HttpMethodRetryHandler)method.getParams().getParameter( HttpMethodParams.RETRY_HANDLER); if (handler == null) {
ntlm.setCredentialCharset(method.getParams().getCredentialCharset()); String response = null; if (this.state == INITIATED || this.state == FAILED) {
String host = method.getParams().getVirtualHost(); if (host == null) { host = conn.getHost();
method.getParams().setDefaults(this.hostConfiguration.getParams());
@Override public HttpVersion getProtocol() { org.apache.commons.httpclient.HttpVersion version = httpMethod .getParams().getVersion(); if (version == null) { return null; } Header connection = httpMethod.getResponseHeader("Connection"); if (protocol == null) { protocol = new HttpVersion("HTTP", version.getMajor(), version.getMinor(), connection != null && KEEP_ALIVE.equalsIgnoreCase(connection .getValue())); } return protocol; }
private HttpMethod getHttpMethod(String pid) { String url = "http://" + host + ":" + port + "/fedora/get/" + pid + "/" + "MDS1"; HttpMethod httpMethod = new GetMethod(url); httpMethod.setDoAuthentication(true); httpMethod.getParams().setParameter("Connection", "Keep-Alive"); return httpMethod; }
HostConfiguration hostCfg = new HostConfiguration(); HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("... your get query string"); int timeout = 5000; //config your value method.getParams().setSoTimeout(timeout); //the call client.executeMethod(hostCfg, method);
private String getUserInformation(String sessionId) { GetClient client = new GetClient(getUserListService()); client.getMethod().getParams().setCookiePolicy(CookiePolicy.RFC_2109); client.setRequestHeader("Cookie", "JSESSIONID=" + sessionId); try { return client.invoke(null); } catch (Exception e) { LOG.error(e.getMessage()); } return null; } }
private void setCookie() { getClient().setEndpoint(super.getEndpoints().get("discovery")); // set sessionId getClient().getMethod().getParams().setCookiePolicy(CookiePolicy.RFC_2109); getClient().setRequestHeader("Cookie", "JSESSIONID=" + sessionId); } }
public static URI newURI(HttpMethod m, HostConfiguration conf) throws URIException { String scheme = conf.getProtocol().getScheme(); String host = conf.getHost(); int port = conf.getPort(); return new URIBuilder().getURI(scheme, host, port, m.getPath(), m.getQueryString(), m.getParams()); } }