Skip to content

Commit

Permalink
Fix for lastest.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Apr 5, 2011
1 parent c190797 commit 843f22e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
25 changes: 0 additions & 25 deletions cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"io"
"os"
"sort"
"strconv"
"strings"
"time"
)
Expand All @@ -30,9 +29,6 @@ func writeSetCookies(w io.Writer, kk []*http.Cookie) os.Error {
b.Reset()
// TODO(petar): c.Value (below) should be unquoted if it is recognized as quoted
fmt.Fprintf(&b, "%s=%s", http.CanonicalHeaderKey(c.Name), c.Value)
if c.Version > 0 {
fmt.Fprintf(&b, "Version=%d; ", c.Version)
}
if len(c.Path) > 0 {
fmt.Fprintf(&b, "; Path=%s", http.URLEscape(c.Path))
}
Expand All @@ -51,9 +47,6 @@ func writeSetCookies(w io.Writer, kk []*http.Cookie) os.Error {
if c.Secure {
fmt.Fprintf(&b, "; Secure")
}
if len(c.Comment) > 0 {
fmt.Fprintf(&b, "; Comment=%s", http.URLEscape(c.Comment))
}
lines = append(lines, "Set-Cookie: "+b.String()+"\r\n")
}
sort.SortStrings(lines)
Expand All @@ -75,9 +68,6 @@ func writeCookies(w io.Writer, kk []*http.Cookie) os.Error {
for _, c := range kk {
b.Reset()
n := c.Name
if c.Version > 0 {
fmt.Fprintf(&b, "$Version=%d; ", c.Version)
}
// TODO(petar): c.Value (below) should be unquoted if it is recognized as quoted
fmt.Fprintf(&b, "%s=%s", http.CanonicalHeaderKey(n), c.Value)
if len(c.Path) > 0 {
Expand All @@ -89,9 +79,6 @@ func writeCookies(w io.Writer, kk []*http.Cookie) os.Error {
if c.HttpOnly {
fmt.Fprintf(&b, "; $HttpOnly")
}
if len(c.Comment) > 0 {
fmt.Fprintf(&b, "; $Comment=%s", http.URLEscape(c.Comment))
}
lines = append(lines, "Cookie: "+b.String()+"\r\n")
}
sort.SortStrings(lines)
Expand Down Expand Up @@ -120,10 +107,8 @@ func readCookies(h http.Header) []*http.Cookie {
}
// Per-line attributes
var lineCookies = make(map[string]string)
var version int
var path string
var domain string
var comment string
var httponly bool
for i := 0; i < len(parts); i++ {
parts[i] = strings.TrimSpace(parts[i])
Expand All @@ -142,20 +127,12 @@ func readCookies(h http.Header) []*http.Cookie {
switch strings.ToLower(attr) {
case "$httponly":
httponly = true
case "$version":
version, err = strconv.Atoi(val)
if err != nil {
version = 0
continue
}
case "$domain":
domain = val
// TODO: Add domain parsing
case "$path":
path = val
// TODO: Add path parsing
case "$comment":
comment = val
default:
lineCookies[attr] = val
}
Expand All @@ -169,8 +146,6 @@ func readCookies(h http.Header) []*http.Cookie {
Value: v,
Path: path,
Domain: domain,
Comment: comment,
Version: version,
HttpOnly: httponly,
MaxAge: -1,
Raw: line,
Expand Down
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func flattenParams(fullParams map[string][]string) map[string]string {

func newRequest(hr *http.Request, hc http.ResponseWriter) *Request {

remoteAddr, _ := net.ResolveTCPAddr(hc.RemoteAddr())
remoteAddr, _ := net.ResolveTCPAddr(hr.RemoteAddr)

req := Request{
Method: hr.Method,
Expand Down
4 changes: 1 addition & 3 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ type httpConn struct {
func (c *httpConn) StartResponse(status int) { c.conn.WriteHeader(status) }

func (c *httpConn) SetHeader(hdr string, val string, unique bool) {
//right now unique can't be implemented through the http package.
//see issue 488
c.conn.SetHeader(hdr, val)
c.conn.Header().Set(hdr, val)
}

func (c *httpConn) WriteString(content string) {
Expand Down

0 comments on commit 843f22e

Please sign in to comment.