Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(39)

Side by Side Diff: src/pkg/net/http/cookie.go

Issue 6822066: code review 6822066: net/http: add Cookie fields to satisfy RFC 6265 section 5.3 (Closed)
Patch Set: diff -r 5bc48b616305 https://code.google.com/p/go Created 11 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package http 5 package http
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "strconv" 10 "strconv"
11 "strings" 11 "strings"
12 "time" 12 "time"
13 ) 13 )
14 14
15 // This implementation is done according to RFC 6265: 15 // This implementation is done according to RFC 6265:
volker.dobler 2012/11/01 09:02:09 This comment might be helpful for Cookie as it wou
16 // 16 //
17 // http://tools.ietf.org/html/rfc6265 17 // http://tools.ietf.org/html/rfc6265
18 18
19 // A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an 19 // A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an
20 // HTTP response or the Cookie header of an HTTP request. 20 // HTTP response or the Cookie header of an HTTP request, or stored in a
21 // CookieJar.
21 type Cookie struct { 22 type Cookie struct {
22 » Name string 23 » Name string
23 » Value string 24 » Value string
24 » Path string 25 » Path string
25 » Domain string 26 » Domain string
27
26 Expires time.Time 28 Expires time.Time
27 RawExpires string 29 RawExpires string
volker.dobler 2012/11/01 09:02:09 The storage model is a mixture of RFC 6265's field
28 30
29 // MaxAge=0 means no 'Max-Age' attribute specified. 31 // MaxAge=0 means no 'Max-Age' attribute specified.
30 // MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0' 32 // MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
31 // MaxAge>0 means Max-Age attribute present and given in seconds 33 // MaxAge>0 means Max-Age attribute present and given in seconds
32 » MaxAge int 34 » MaxAge int
33 » Secure bool 35
34 » HttpOnly bool 36 » Creation time.Time
volker.dobler 2012/11/01 09:02:09 As Brad mentioned in his review: Some of these fie
37 » LastAccess time.Time
38
39 » Persistent bool
40 » HostOnly bool
41 » Secure bool
42 » HttpOnly bool
43
35 Raw string 44 Raw string
36 Unparsed []string // Raw text of unparsed attribute-value pairs 45 Unparsed []string // Raw text of unparsed attribute-value pairs
37 } 46 }
38 47
39 // readSetCookies parses all "Set-Cookie" values from 48 // readSetCookies parses all "Set-Cookie" values from
40 // the header h and returns the successfully parsed Cookies. 49 // the header h and returns the successfully parsed Cookies.
41 func readSetCookies(h Header) []*Cookie { 50 func readSetCookies(h Header) []*Cookie {
42 cookies := []*Cookie{} 51 cookies := []*Cookie{}
43 for _, line := range h["Set-Cookie"] { 52 for _, line := range h["Set-Cookie"] {
44 parts := strings.Split(strings.TrimSpace(line), ";") 53 parts := strings.Split(strings.TrimSpace(line), ";")
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if !validByte(raw[i]) { 262 if !validByte(raw[i]) {
254 return "", false 263 return "", false
255 } 264 }
256 } 265 }
257 return raw, true 266 return raw, true
258 } 267 }
259 268
260 func isCookieNameValid(raw string) bool { 269 func isCookieNameValid(raw string) bool {
261 return strings.IndexFunc(raw, isNotToken) < 0 270 return strings.IndexFunc(raw, isNotToken) < 0
262 } 271 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b