diff options
| author | Rob Pike <r@golang.org> | 2011-06-28 09:43:14 +1000 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2011-06-28 09:43:14 +1000 |
| commit | ebb1566a46f2f5b2c06ef0f7ad5f7084dce0aed9 (patch) | |
| tree | 62c412f896baa504ae4a26d452f8cac6ce1aeed8 /src/pkg/http | |
| parent | 82a8afdf1411bbe5b08b09d1e94a8d1c4fb5635c (diff) | |
| download | go-ebb1566a46f2f5b2c06ef0f7ad5f7084dce0aed9.tar.xz | |
strings.Split: make the default to split all.
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.
R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
Diffstat (limited to 'src/pkg/http')
| -rw-r--r-- | src/pkg/http/cgi/host.go | 2 | ||||
| -rw-r--r-- | src/pkg/http/cgi/host_test.go | 2 | ||||
| -rw-r--r-- | src/pkg/http/cookie.go | 4 | ||||
| -rw-r--r-- | src/pkg/http/fs.go | 2 | ||||
| -rw-r--r-- | src/pkg/http/request.go | 8 | ||||
| -rw-r--r-- | src/pkg/http/response.go | 2 | ||||
| -rw-r--r-- | src/pkg/http/server.go | 2 | ||||
| -rw-r--r-- | src/pkg/http/spdy/read.go | 2 | ||||
| -rw-r--r-- | src/pkg/http/transfer.go | 4 | ||||
| -rw-r--r-- | src/pkg/http/transport.go | 4 | ||||
| -rw-r--r-- | src/pkg/http/url.go | 4 |
11 files changed, 18 insertions, 18 deletions
diff --git a/src/pkg/http/cgi/host.go b/src/pkg/http/cgi/host.go index 2be3ede774..01a941650b 100644 --- a/src/pkg/http/cgi/host.go +++ b/src/pkg/http/cgi/host.go @@ -197,7 +197,7 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { if len(line) == 0 { break } - parts := strings.Split(string(line), ":", 2) + parts := strings.SplitN(string(line), ":", 2) if len(parts) < 2 { h.printf("cgi: bogus header line: %s", string(line)) continue diff --git a/src/pkg/http/cgi/host_test.go b/src/pkg/http/cgi/host_test.go index bbdb715cf9..3b9dad5c0c 100644 --- a/src/pkg/http/cgi/host_test.go +++ b/src/pkg/http/cgi/host_test.go @@ -46,7 +46,7 @@ readlines: } linesRead++ trimmedLine := strings.TrimRight(line, "\r\n") - split := strings.Split(trimmedLine, "=", 2) + split := strings.SplitN(trimmedLine, "=", 2) if len(split) != 2 { t.Fatalf("Unexpected %d parts from invalid line number %v: %q; existing map=%v", len(split), linesRead, line, m) diff --git a/src/pkg/http/cookie.go b/src/pkg/http/cookie.go index 79c239b46e..fe70431bbb 100644 --- a/src/pkg/http/cookie.go +++ b/src/pkg/http/cookie.go @@ -41,7 +41,7 @@ type Cookie struct { func readSetCookies(h Header) []*Cookie { cookies := []*Cookie{} for _, line := range h["Set-Cookie"] { - parts := strings.Split(strings.TrimSpace(line), ";", -1) + parts := strings.Split(strings.TrimSpace(line), ";") if len(parts) == 1 && parts[0] == "" { continue } @@ -175,7 +175,7 @@ func readCookies(h Header, filter string) []*Cookie { } for _, line := range lines { - parts := strings.Split(strings.TrimSpace(line), ";", -1) + parts := strings.Split(strings.TrimSpace(line), ";") if len(parts) == 1 && parts[0] == "" { continue } diff --git a/src/pkg/http/fs.go b/src/pkg/http/fs.go index 139fe2cb0f..0b830053a9 100644 --- a/src/pkg/http/fs.go +++ b/src/pkg/http/fs.go @@ -259,7 +259,7 @@ func parseRange(s string, size int64) ([]httpRange, os.Error) { return nil, os.NewError("invalid range") } var ranges []httpRange - for _, ra := range strings.Split(s[len(b):], ",", -1) { + for _, ra := range strings.Split(s[len(b):], ",") { i := strings.Index(ra, "-") if i < 0 { return nil, os.NewError("invalid range") diff --git a/src/pkg/http/request.go b/src/pkg/http/request.go index cd6965fa5d..456476a212 100644 --- a/src/pkg/http/request.go +++ b/src/pkg/http/request.go @@ -543,7 +543,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) { } var f []string - if f = strings.Split(s, " ", 3); len(f) < 3 { + if f = strings.SplitN(s, " ", 3); len(f) < 3 { return nil, &badStringError{"malformed HTTP request", s} } req.Method, req.RawURL, req.Proto = f[0], f[1], f[2] @@ -662,11 +662,11 @@ func ParseQuery(query string) (m Values, err os.Error) { } func parseQuery(m Values, query string) (err os.Error) { - for _, kv := range strings.Split(query, "&", -1) { + for _, kv := range strings.Split(query, "&") { if len(kv) == 0 { continue } - kvPair := strings.Split(kv, "=", 2) + kvPair := strings.SplitN(kv, "=", 2) var key, value string var e os.Error @@ -703,7 +703,7 @@ func (r *Request) ParseForm() (err os.Error) { return os.NewError("missing form body") } ct := r.Header.Get("Content-Type") - switch strings.Split(ct, ";", 2)[0] { + switch strings.SplitN(ct, ";", 2)[0] { case "text/plain", "application/x-www-form-urlencoded", "": const maxFormSize = int64(10 << 20) // 10 MB is a lot of text. b, e := ioutil.ReadAll(io.LimitReader(r.Body, maxFormSize+1)) diff --git a/src/pkg/http/response.go b/src/pkg/http/response.go index 6c0c441a94..915327a69e 100644 --- a/src/pkg/http/response.go +++ b/src/pkg/http/response.go @@ -95,7 +95,7 @@ func ReadResponse(r *bufio.Reader, req *Request) (resp *Response, err os.Error) } return nil, err } - f := strings.Split(line, " ", 3) + f := strings.SplitN(line, " ", 3) if len(f) < 2 { return nil, &badStringError{"malformed HTTP response", line} } diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go index 08cbed7ad8..ab960f4f0a 100644 --- a/src/pkg/http/server.go +++ b/src/pkg/http/server.go @@ -421,7 +421,7 @@ func errorKludge(w *response) { msg += " would ignore this error page if this text weren't here.\n" // Is it text? ("Content-Type" is always in the map) - baseType := strings.Split(w.header.Get("Content-Type"), ";", 2)[0] + baseType := strings.SplitN(w.header.Get("Content-Type"), ";", 2)[0] switch baseType { case "text/html": io.WriteString(w, "<!-- ") diff --git a/src/pkg/http/spdy/read.go b/src/pkg/http/spdy/read.go index 8adec7bd4f..c6b6ab3af8 100644 --- a/src/pkg/http/spdy/read.go +++ b/src/pkg/http/spdy/read.go @@ -174,7 +174,7 @@ func parseHeaderValueBlock(r io.Reader, streamId uint32) (http.Header, os.Error) if _, err := io.ReadFull(r, value); err != nil { return nil, err } - valueList := strings.Split(string(value), "\x00", -1) + valueList := strings.Split(string(value), "\x00") for _, v := range valueList { h.Add(name, v) } diff --git a/src/pkg/http/transfer.go b/src/pkg/http/transfer.go index f72c3d239a..2502c1fee1 100644 --- a/src/pkg/http/transfer.go +++ b/src/pkg/http/transfer.go @@ -334,7 +334,7 @@ func fixTransferEncoding(requestMethod string, header Header) ([]string, os.Erro return nil, nil } - encodings := strings.Split(raw[0], ",", -1) + encodings := strings.Split(raw[0], ",") te := make([]string, 0, len(encodings)) // TODO: Even though we only support "identity" and "chunked" // encodings, the loop below is designed with foresight. One @@ -450,7 +450,7 @@ func fixTrailer(header Header, te []string) (Header, os.Error) { header.Del("Trailer") trailer := make(Header) - keys := strings.Split(raw, ",", -1) + keys := strings.Split(raw, ",") for _, key := range keys { key = CanonicalHeaderKey(strings.TrimSpace(key)) switch key { diff --git a/src/pkg/http/transport.go b/src/pkg/http/transport.go index 9ad159010b..3c16c880d5 100644 --- a/src/pkg/http/transport.go +++ b/src/pkg/http/transport.go @@ -329,7 +329,7 @@ func (t *Transport) getConn(cm *connectMethod) (*persistConn, os.Error) { return nil, err } if resp.StatusCode != 200 { - f := strings.Split(resp.Status, " ", 2) + f := strings.SplitN(resp.Status, " ", 2) conn.Close() return nil, os.NewError(f[1]) } @@ -383,7 +383,7 @@ func useProxy(addr string) bool { addr = addr[:strings.LastIndex(addr, ":")] } - for _, p := range strings.Split(no_proxy, ",", -1) { + for _, p := range strings.Split(no_proxy, ",") { p = strings.ToLower(strings.TrimSpace(p)) if len(p) == 0 { continue diff --git a/src/pkg/http/url.go b/src/pkg/http/url.go index beb0b8200d..e934b27c4d 100644 --- a/src/pkg/http/url.go +++ b/src/pkg/http/url.go @@ -508,8 +508,8 @@ func (v Values) Encode() string { // resolvePath applies special path segments from refs and applies // them to base, per RFC 2396. func resolvePath(basepath string, refpath string) string { - base := strings.Split(basepath, "/", -1) - refs := strings.Split(refpath, "/", -1) + base := strings.Split(basepath, "/") + refs := strings.Split(refpath, "/") if len(base) == 0 { base = []string{""} } |
