/** * Returns the charset to be used for parsing URIs. * @return The charset */ public String getUriCharset() { String charset = (String) getParameter(HTTP_URI_CHARSET); if (charset == null) { charset = "UTF-8"; } return charset; }
/** * Returns the virtual host name. * * @return The virtual host name */ public String getVirtualHost() { return (String) getParameter(VIRTUAL_HOST); }
/** * Returns {@link HttpVersion HTTP protocol version} to be used by the * {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that * this collection of parameters applies to. * * @return {@link HttpVersion HTTP protocol version} */ public HttpVersion getVersion() { Object param = getParameter(PROTOCOL_VERSION); if (param == null) { return HttpVersion.HTTP_1_1; } return (HttpVersion)param; }
/** * Returns {@link CookiePolicy cookie policy} to be used by the * {@link org.apache.commons.httpclient.HttpMethod HTTP methods} * this collection of parameters applies to. * * @return {@link CookiePolicy cookie policy} */ public String getCookiePolicy() { Object param = getParameter(COOKIE_POLICY); if (param == null) { return CookiePolicy.DEFAULT; } return (String)param; }
/** * Returns the charset to be used for writing HTTP headers. * @return The charset */ public String getHttpElementCharset() { String charset = (String) getParameter(HTTP_ELEMENT_CHARSET); if (charset == null) { LOG.warn("HTTP element charset not configured, using US-ASCII"); charset = "US-ASCII"; } return charset; }
/** * Returns the default charset to be used for writing content body, * when no charset explicitly specified. * @return The charset */ public String getContentCharset() { String charset = (String) getParameter(HTTP_CONTENT_CHARSET); if (charset == null) { LOG.warn("Default content charset not configured, using ISO-8859-1"); charset = "ISO-8859-1"; } return charset; }
/** * Returns the charset to be used for {@link org.apache.commons.httpclient.Credentials}. If * not configured the {@link #HTTP_ELEMENT_CHARSET HTTP element charset} is used. * @return The charset */ public String getCredentialCharset() { String charset = (String) getParameter(CREDENTIAL_CHARSET); if (charset == null) { LOG.debug("Credential charset not configured, using HTTP element charset"); charset = getHttpElementCharset(); } return charset; }
/** * Returns the MIME boundary string that is used to demarcate boundaries of * this part. The first call to this method will implicitly create a new * boundary string. To create a boundary string first the * HttpMethodParams.MULTIPART_BOUNDARY parameter is considered. Otherwise * a random one is generated. * * @return The boundary string of this entity in ASCII encoding. */ protected byte[] getMultipartBoundary() { if (multipartBoundary == null) { String temp = (String) params.getParameter(HttpMethodParams.MULTIPART_BOUNDARY); if (temp != null) { multipartBoundary = EncodingUtil.getAsciiBytes(temp); } else { multipartBoundary = generateMultipartBoundary(); } } return multipartBoundary; }
/** * Generates default <tt>User-Agent</tt> request header, as long as no * <tt>User-Agent</tt> request header already exists. * * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @throws IOException if an I/O (transport) error occurs. Some transport exceptions * can be recovered from. * @throws HttpException if a protocol exception occurs. Usually protocol exceptions * cannot be recovered from. */ protected void addUserAgentRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException { LOG.trace("enter HttpMethodBase.addUserAgentRequestHeaders(HttpState, " + "HttpConnection)"); if (getRequestHeader("User-Agent") == null) { String agent = (String)getParams().getParameter(HttpMethodParams.USER_AGENT); if (agent == null) { agent = "Jakarta Commons-HttpClient"; } setRequestHeader("User-Agent", agent); } }
/** * 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); }
/** * Returns the actual cookie policy * * @param state HTTP state. TODO: to be removed in the future * * @return cookie spec */ private CookieSpec getCookieSpec(final HttpState state) { if (this.cookiespec == null) { int i = state.getCookiePolicy(); if (i == -1) { this.cookiespec = CookiePolicy.getCookieSpec(this.params.getCookiePolicy()); } else { this.cookiespec = CookiePolicy.getSpecByPolicy(i); } this.cookiespec.setValidDateFormats( (Collection)this.params.getParameter(HttpMethodParams.DATE_PATTERNS)); } return this.cookiespec; }
(HttpMethodRetryHandler)method.getParams().getParameter( HttpMethodParams.RETRY_HANDLER); if (handler == null) {
/** * Returns the virtual host name. * * @return The virtual host name */ public String getVirtualHost() { return (String) getParameter(VIRTUAL_HOST); }
/** * Returns the charset to be used for parsing URIs. * @return The charset */ public String getUriCharset() { String charset = (String) getParameter(HTTP_URI_CHARSET); if (charset == null) { charset = "UTF-8"; } return charset; }
/** * Returns the charset to be used for parsing URIs. * @return The charset */ public String getUriCharset() { String charset = (String) getParameter(HTTP_URI_CHARSET); if (charset == null) { charset = "UTF-8"; } return charset; }
/** * Returns the charset to be used for parsing URIs. * @return The charset */ public String getUriCharset() { String charset = (String) getParameter(HTTP_URI_CHARSET); if (charset == null) { charset = "UTF-8"; } return charset; }
/** * Returns the charset to be used for writing HTTP headers. * @return The charset */ public String getHttpElementCharset() { String charset = (String) getParameter(HTTP_ELEMENT_CHARSET); if (charset == null) { LOG.warn("HTTP element charset not configured, using US-ASCII"); charset = "US-ASCII"; } return charset; }
public Object getResponseParameter(String name) { if(this.method == null) return null; return this.method.getParams().getParameter(name); }
public Object getMethodParameter(String key) { if (method == null) return null; return method.getParams().getParameter(key); }
public Object getResponseParameter(String name) { if (method == null) return null; return method.getParams().getParameter(name); }