⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cookie.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
package com.maverick.http;

import java.util.Date;
import java.util.StringTokenizer;
import java.text.SimpleDateFormat;
import java.text.ParseException;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Cookie {

    String name;
    String value;
    String path = "";
    Date expires = null;
    String domain = "";
    boolean secure = false;

    static SimpleDateFormat format = new SimpleDateFormat("EEE, DD-MMM-yyyy HH:mm:ss z");

    public Cookie(String setCookieHeaderValue) {

        StringTokenizer tokens = new StringTokenizer(setCookieHeaderValue, ";");
        while(tokens.hasMoreTokens()) {
            String pair = tokens.nextToken();
            int idx = pair.indexOf('=');
            if(idx > -1) {
                String name = pair.substring(0, idx).trim();
                String value = pair.substring(idx+1).trim();

                if(name.equalsIgnoreCase("expires")) {
                    try {
                      int e = Integer.parseInt(value);
                    } catch(NumberFormatException ex) {
                        try {
                            expires = format.parse(value);
                        } catch(ParseException ex2) {

                        }
                    }
                } else if(name.equalsIgnoreCase("path")) {
                    this.path = value;
                } else if(name.equalsIgnoreCase("domain")) {
                    this.domain = path;
                } else {
                    this.name = name;
                    this.value = value;
                }
            } else if(pair.trim().equalsIgnoreCase("secure"))
                secure = true;
        }

    }

    public String getPath() {
        return path;
    }

    public String getDomain() {
        return domain;
    }

    public boolean isSecure() {
        return secure;
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    public Date getExpires() {
        return expires;
    }

    public String toString() {
        return name + "=" + value;

        /*        + (expires!=null ? format.format(expires) + "; " : "")
                + (path!=null ? "path=" + path + "; " : "")
                + (domain!=null ? "domain=" + domain + "; " : "")
                + (secure ? "secure" : "");*/
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -