Permalink
Browse files

Updates for Go r.59

  • Loading branch information...
kpumuk committed Aug 3, 2011
1 parent 9e4be1f commit 111463f1adef3302a37f820c8e8fc13b8935fd65
Showing with 17 additions and 17 deletions.
  1. +3 −3 cookie.go
  2. +6 −6 request.go
  3. +2 −2 scgi.go
  4. +1 −1 web.go
  5. +5 −5 web_test.go
View
@@ -108,7 +108,7 @@ func writeSetCookies(w io.Writer, kk []*http.Cookie) os.Error {
}
lines = append(lines, "Set-Cookie: "+b.String()+"\r\n")
}
- sort.SortStrings(lines)
+ sort.Strings(lines)
for _, l := range lines {
if _, err := io.WriteString(w, l); err != nil {
return err
@@ -140,7 +140,7 @@ func writeCookies(w io.Writer, kk []*http.Cookie) os.Error {
}
lines = append(lines, "Cookie: "+b.String()+"\r\n")
}
- sort.SortStrings(lines)
+ sort.Strings(lines)
for _, l := range lines {
if _, err := io.WriteString(w, l); err != nil {
return err
@@ -160,7 +160,7 @@ func readCookies(h http.Header) []*http.Cookie {
}
unparsedLines := []string{}
for _, line := range lines {
- parts := strings.Split(strings.TrimSpace(line), ";", -1)
+ parts := strings.Split(strings.TrimSpace(line), ";")
if len(parts) == 1 && parts[0] == "" {
continue
}
View
@@ -77,10 +77,10 @@ func newRequest(hr *http.Request, hc http.ResponseWriter) *Request {
Body: hr.Body,
Close: hr.Close,
Host: hr.Host,
- Referer: hr.Referer,
- UserAgent: hr.UserAgent,
+ Referer: hr.Referer(),
+ UserAgent: hr.UserAgent(),
FullParams: hr.Form,
- Cookie: hr.Cookie,
+ Cookie: hr.Cookies(),
RemoteAddr: remoteAddr.IP.String(),
RemotePort: remoteAddr.Port,
}
@@ -141,8 +141,8 @@ func newRequestCgi(headers http.Header, body io.Reader) *Request {
func parseForm(m map[string][]string, query string) (err os.Error) {
data := make(map[string]*vector.StringVector)
- for _, kv := range strings.Split(query, "&", -1) {
- kvPair := strings.Split(kv, "=", 2)
+ for _, kv := range strings.Split(query, "&") {
+ kvPair := strings.SplitN(kv, "=", 2)
var key, value string
var e os.Error
@@ -185,7 +185,7 @@ func (r *Request) parseParams() (err os.Error) {
}
ct := r.Headers.Get("Content-Type")
- switch strings.Split(ct, ";", 2)[0] {
+ switch strings.SplitN(ct, ";", 2)[0] {
case "text/plain", "application/x-www-form-urlencoded", "":
var b []byte
if b, err = ioutil.ReadAll(r.Body); err != nil {
View
@@ -89,7 +89,7 @@ func readScgiRequest(buf *bytes.Buffer) (*Request, os.Error) {
var err os.Error
//find the CONTENT_LENGTH
- clfields := bytes.Split(data, []byte{0}, 3)
+ clfields := bytes.SplitN(data, []byte{0}, 3)
if len(clfields) != 3 {
return nil, os.NewError("Invalid SCGI Request -- no fields")
}
@@ -105,7 +105,7 @@ func readScgiRequest(buf *bytes.Buffer) (*Request, os.Error) {
content := data[len(data)-clen:]
- fields := bytes.Split(data[0:len(data)-clen], []byte{0}, -1)
+ fields := bytes.Split(data[0:len(data)-clen], []byte{0})
for i := 0; i < len(fields)-1; i += 2 {
key := string(fields[i])
View
2 web.go
@@ -136,7 +136,7 @@ func (ctx *Context) GetSecureCookie(name string) (string, bool) {
continue
}
- parts := strings.Split(cookie.Value, "|", 3)
+ parts := strings.SplitN(cookie.Value, "|", 3)
val := parts[0]
timestamp := parts[1]
View
@@ -46,21 +46,21 @@ func buildTestResponse(buf *bytes.Buffer) *testResponse {
response := testResponse{headers: make(map[string][]string), cookies: make(map[string]string)}
s := buf.String()
- contents := strings.Split(s, "\r\n\r\n", 2)
+ contents := strings.SplitN(s, "\r\n\r\n", 2)
header := contents[0]
if len(contents) > 1 {
response.body = contents[1]
}
- headers := strings.Split(header, "\r\n", -1)
+ headers := strings.Split(header, "\r\n")
- statusParts := strings.Split(headers[0], " ", 3)
+ statusParts := strings.SplitN(headers[0], " ", 3)
response.statusCode, _ = strconv.Atoi(statusParts[1])
for _, h := range headers[1:] {
- split := strings.Split(h, ":", 2)
+ split := strings.SplitN(h, ":", 2)
name := strings.TrimSpace(split[0])
value := strings.TrimSpace(split[1])
if _, ok := response.headers[name]; !ok {
@@ -76,7 +76,7 @@ func buildTestResponse(buf *bytes.Buffer) *testResponse {
if name == "Set-Cookie" {
i := strings.Index(value, ";")
cookie := value[0:i]
- cookieParts := strings.Split(cookie, "=", 2)
+ cookieParts := strings.SplitN(cookie, "=", 2)
response.cookies[strings.TrimSpace(cookieParts[0])] = strings.TrimSpace(cookieParts[1])
}
}

0 comments on commit 111463f

Please sign in to comment.