カテゴリー
Wiki内検索
*
最近更新したページ
最新コメント
win32/guitest by stunning seo guys
FrontPage by stunning seo guys
SWIG by awesome things!
Win32/Console by stunning seo guys
FrontPage by awesome things!
Win32SDK_ICM by stunning seo guys
Win32SDK_MM by check it out
Win32SDK_process by stunning seo guys
VisualuRuby by stunning seo guys

HttpClient

Jakarta Commons HttpClient


リンク

Jakarta Commons HttpClient
http://jakarta.apache.org/commons/httpclient/

メモ


HttpClient client = new HttpClient();
// ポリシーの設定
client.getParams().setCookiePolicy(
        CookiePolicy.BROWSER_COMPATIBILITY);
// Cookieヘッダを一行で送信
client.getParams().setBooleanParameter(
        HttpMethodParams.SINGLE_COOKIE_HEADER, true);
// デフォルトの文字コード
client.getParams().setContentCharset("shift_jis");

Cookie


CookiePolicy
  • BROWSER_COMPATIBILITY
  • NETSCAPE
  • RFC_2109
  • IGNORE_COOKIES
  • DEFAULT ・・・ RFC_2109

// CookieSpecBase

/**
 * Performs domain-match as implemented in common browsers.
 * @param host The target host.
 * @param domain The cookie domain attribute.
 * @return true if the specified host matches the given domain.
 */
public boolean domainMatch(final String host, String domain) {
    if (host.equals(domain)) {
        return true;
    }
    if (!domain.startsWith(".")) {
        domain = "." + domain;
    }
    return host.endsWith(domain) || host.equals(domain.substring(1));
}

/**
 * Performs path-match as implemented in common browsers.
 * @param path The target path.
 * @param topmostPath The cookie path attribute.
 * @return true if the paths match
 */
public boolean pathMatch(final String path, final String topmostPath) {
    boolean match = path.startsWith (topmostPath);
    // if there is a match and these values are not exactly the same we have
    // to make sure we're not matcing "/foobar" and "/foo"
    if (match && path.length() != topmostPath.length()) {
        if (!topmostPath.endsWith(PATH_DELIM)) {
            match = (path.charAt(topmostPath.length()) == PATH_DELIM_CHAR);
        }
    }
    return match;
}

// NetscapeDraftSpec < CookieSpecBase
 
/**
 * Performs domain-match as described in the Netscape draft.
 * @param host The target host.
 * @param domain The cookie domain attribute.
 * @return true if the specified host matches the given domain.
 */
public boolean domainMatch(final String host, final String domain) {
    return host.endsWith(domain);
}

// RFC2109Spec < CookieSpecBase

/**
 * Performs domain-match as defined by the RFC2109.
 * @param host The target host.
 * @param domain The cookie domain attribute.
 * @return true if the specified host matches the given domain.
 * 
 * @since 3.0
 */ 
public boolean domainMatch(String host, String domain) {
    boolean match = host.equals(domain) 
        || (domain.startsWith(".") && host.endsWith(domain));

    return match;
}
2006年03月10日(金) 23:40:36 Modified by aqualung




スマートフォン版で見る