Skip to content

Commit

Permalink
update for gc weekly.2011-07-07
Browse files Browse the repository at this point in the history
  • Loading branch information
fiber committed Jul 9, 2011
1 parent 79dc98d commit 3b40eac
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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
Expand Down Expand Up @@ -81,7 +81,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
Expand All @@ -101,7 +101,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
}
Expand Down
6 changes: 3 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions scgi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion web.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,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]
Expand Down
10 changes: 5 additions & 5 deletions web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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])
}
}
Expand Down

0 comments on commit 3b40eac

Please sign in to comment.