↓ 로그인 후
구글 검색 결과를 몇 개씩 보여줄 건가, duckduckgo 사이트의 사용자 테마와 같은 설정 등이 있습니다.GET /test HTTP/1.1 Host: localhost:8080 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 DNT: 1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: ko,en-US;q=0.9,en;q=0.8
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: CookieName1=Example1; Expires=Tue, 27-Nov-2018 02:53:13 GMT Set-Cookie: CookieName2=Example2; Expires=Tue, 27-Nov-2018 02:53:13 GMT Set-Cookie: JSESSIONID=8EB8434C5776358C84017077E11A3300; Path=/ Content-Type: text/html;charset=ISO-8859-1 Content-Language: ko Content-Length: 316
GET /test HTTP/1.1 Host: localhost:8080 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 DNT: 1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: ko,en-US;q=0.9,en;q=0.8 Cookie: JSESSIONID=8EB8434C5776358C84017077E11A3300; CookieName1=Example1; CookieName2=Example2
Expires나 Max-Age를 명시하지 않으면 클라이언트가 종료될 때 삭제되는 세션 쿠키가 생성됩니다.Expires나 Max-Age를 명시하게 되면 명시된 시간까지 계속 유지 가능한 쿠키가 생성됩니다.secure 플래그를 추가해서 생성하며 HTTPS로 전송하기 때문에 쿠키를 열어보는 걸 방지할 수 있습니다.XSS 위협을 없애줍니다.cross-site tracing (XST) 와 cross-site request forgery (XSRF) 공격에 공격받기 쉽습니다.HttpOnly 플래그를 쿠키에 추가하여 생성합니다.Name, Value, Expires, Domain, Path, Secure, 가 있습니다.Name, Value, Comment, Domain, Max-Age, Path, Secure, Version이 있습니다.Expires를 사용하고 RFC 2109 쿠키는 delta-seconds를 사용합니다.; , ' ' 만 허용하지 않았으나 RFC 2109는 더 많고 다양한 특수 문자가 허용되지 않습니다.속성-값 쌍에서 “로 싸여 있는 문자열을 허용하지 않지만, RFC 2109 쿠키는 허용합니다.속성=값에서 = 주변에 공백을 허용하지 않지만, RFC 2109 쿠키는 허용합니다.RFC 2109는 제일 처음 쿠키의 개념과 문법에 관해서만 설명했지만, RFC 6265는 인터넷상에서 실제로 어떻게 구현해서 사용해야 하는지를 설명했습니다.Set-Cookie 헤더를 이용합니다.RFC 2109의 쿠키 속성은 쿠키 Name, Value, Comment, Domain, Max-Age, Path, Secure, Version이 있습니다.RFC 6265의 쿠키 속성은 쿠키 Name, Value, Expires, Domain, Max-Age, Path, Secure, HttpOnly가 있습니다.Comment는 서버가 쿠키의 용도를 기록해두기 위한 속성, Version은 쿠키가 어떤 명세서를 따르는지 버전을 나타냅니다.Expires는 Date 값을 가지고 있으며 이 날짜가 지나면 쿠키를 버리고, HttpOnly는 비HTTP 요청을 막습니다. (클라이언트가 API로 접근하는 행위 등)RFC 2109는 유저 에이전트가 최소 300개의 쿠키, 쿠키마다 적어도 4096바이트, 한 호스트나 도메인 마다 최소 20개를 지원해야 한다고 명시했습니다.RFC 6265는 유저 에이전트가 최소 3000개의 쿠키, 쿠키마다 적어도 4096바이트, 도메인당 최소 50개의 쿠키를 저장 가능해야 한다고 명시했습니다.RFC 6265는 속성이름과 세미콜론 사이에 공백이 필요하고 특수 문자가 있는 경우를 제외하면 속성 값을 ”“로 감싸지 않습니다.RFC 6265는 유저 에이전트가 Set-Cookie 헤더를 어떻게 처리해야 하는지 알고리즘을 제공합니다.
* This class supports both the RFC 2109 and the RFC 6265 specifications.
* By default, cookies are created using RFC 6265.
/**
* Sets the version of the cookie protocol this cookie complies with.
* Version 0 complies with the original Netscape cookie specification.
* Version 1 complies with RFC 2109.
* <p>
* Since RFC 2109 is still somewhat new, consider version 1 as experimental;
* do not use it yet on production sites.
*
* @param v
* 0 if the cookie should comply with the original Netscape
* specification; 1 if the cookie should comply with RFC 2109
* @see #getVersion
*/
public void setVersion(int v) {
version = v;
}
Expires가 생겼다고 적혀있으나 maxAge만 있습니다.private final String name; private String value; private int version = 0; // ;Version=1 ... means RFC 2109 style // // Attributes encoded in the header's cookie fields. // private String comment; // ;Comment=VALUE ... describes cookie's use private String domain; // ;Domain=VALUE ... domain that sees cookie private int maxAge = -1; // ;Max-Age=VALUE ... cookies auto-expire private String path; // ;Path=VALUE ... URLs that see the cookie private boolean secure; // ;Secure ... e.g. use SSL private boolean httpOnly; // Not in cookie specs, but supported by browsers
HTTP/1.1 401 Unauthorized
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 10:00:00 EST
WWW-Authenticate: Basic realm="Tomcat Manager Application"
Set-Cookie: JSESSIONID=****removed****; Path=/manager
WWW-AuthenticateREDUNDANT: Basic realm="Tomcat Manager Application"
Content-Type: text/html
Transfer-Encoding: chunked
Vary: Accept-Encoding
Date: Mon, 26 Mar 2012 03:39:09 GMT
Server: Coyote
/**
* This array is a lookup table that translates 6-bit positive integer
* index values into their "Base64 Alphabet" equivalents as specified
* in "Table 1: The Base64 Alphabet" of RFC 2045 (and RFC 4648).
*/
private static final char[] toBase64 = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
};
/**
* It's the lookup table for "URL and Filename safe Base64" as specified
* in Table 2 of the RFC 4648, with the '+' and '/' changed to '-' and
* '_'. This table is used when BASE64_URL is specified.
*/
private static final char[] toBase64URL = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'
};
makeCookie(response, "(CookieName1)", "Bracket");
makeCookie(response, "{CookieName2}", "Bracket");
makeCookie(response, "[CookieName3]", "Bracket");
makeCookie(response, "CookieName4", "(Bracket)");
makeCookie(response, "CookieName5", "{Bracket}");
makeCookie(response, "CookieName6", "[Bracket]");
↓ 결과