aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorMarvin Stenger <marvin.stenger94@gmail.com>2017-10-05 15:50:11 +0200
committerIan Lance Taylor <iant@golang.org>2017-10-05 23:19:42 +0000
commitd153df8e4b5874692f4948e9c8e10720446058e3 (patch)
tree84567a80b3f90d91bb6d1832073505427c51d67c /src/net/http
parent90d71fe99e21b68e292327c966946f1706d66514 (diff)
downloadgo-d153df8e4b5874692f4948e9c8e10720446058e3.tar.xz
all: revert "all: prefer strings.LastIndexByte over strings.LastIndex"
This reverts https://golang.org/cl/66372. Updates #22148 Change-Id: I3e94af3dfc11a2883bf28e1d5e1f32f98760b3ee Reviewed-on: https://go-review.googlesource.com/68431 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/cookiejar/jar.go6
-rw-r--r--src/net/http/cookiejar/jar_test.go2
-rw-r--r--src/net/http/http.go2
-rw-r--r--src/net/http/request.go4
-rw-r--r--src/net/http/transport.go6
5 files changed, 10 insertions, 10 deletions
diff --git a/src/net/http/cookiejar/jar.go b/src/net/http/cookiejar/jar.go
index f147eceb18..ef8c35bf0a 100644
--- a/src/net/http/cookiejar/jar.go
+++ b/src/net/http/cookiejar/jar.go
@@ -330,7 +330,7 @@ func jarKey(host string, psl PublicSuffixList) string {
var i int
if psl == nil {
- i = strings.LastIndexByte(host, '.')
+ i = strings.LastIndex(host, ".")
if i <= 0 {
return host
}
@@ -349,7 +349,7 @@ func jarKey(host string, psl PublicSuffixList) string {
// here on, so it is okay if psl.PublicSuffix("www.buggy.psl")
// returns "com" as the jar key is generated from host.
}
- prevDot := strings.LastIndexByte(host[:i-1], '.')
+ prevDot := strings.LastIndex(host[:i-1], ".")
return host[prevDot+1:]
}
@@ -365,7 +365,7 @@ func defaultPath(path string) string {
return "/" // Path is empty or malformed.
}
- i := strings.LastIndexByte(path, '/') // Path starts with "/", so i != -1.
+ i := strings.LastIndex(path, "/") // Path starts with "/", so i != -1.
if i == 0 {
return "/" // Path has the form "/abc".
}
diff --git a/src/net/http/cookiejar/jar_test.go b/src/net/http/cookiejar/jar_test.go
index ed4baae4c6..47fb1abdaa 100644
--- a/src/net/http/cookiejar/jar_test.go
+++ b/src/net/http/cookiejar/jar_test.go
@@ -37,7 +37,7 @@ func (testPSL) PublicSuffix(d string) string {
if d == "www2.buggy.psl" {
return "com"
}
- return d[strings.LastIndexByte(d, '.')+1:]
+ return d[strings.LastIndex(d, ".")+1:]
}
// newTestJar creates an empty Jar with testPSL as the public suffix list.
diff --git a/src/net/http/http.go b/src/net/http/http.go
index 7d5b74092e..b95ca89f40 100644
--- a/src/net/http/http.go
+++ b/src/net/http/http.go
@@ -35,7 +35,7 @@ func (k *contextKey) String() string { return "net/http context value " + k.name
// Given a string of the form "host", "host:port", or "[ipv6::address]:port",
// return true if the string includes a port.
-func hasPort(s string) bool { return strings.LastIndexByte(s, ':') > strings.LastIndexByte(s, ']') }
+func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastIndex(s, "]") }
// removeEmptyPort strips the empty port in ":port" to ""
// as mandated by RFC 3986 Section 6.2.3.
diff --git a/src/net/http/request.go b/src/net/http/request.go
index 801d00ef2f..870af85e04 100644
--- a/src/net/http/request.go
+++ b/src/net/http/request.go
@@ -688,11 +688,11 @@ func removeZone(host string) string {
if !strings.HasPrefix(host, "[") {
return host
}
- i := strings.LastIndexByte(host, ']')
+ i := strings.LastIndex(host, "]")
if i < 0 {
return host
}
- j := strings.LastIndexByte(host[:i], '%')
+ j := strings.LastIndex(host[:i], "%")
if j < 0 {
return host
}
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
index 034d016cb3..5f2ace7b4b 100644
--- a/src/net/http/transport.go
+++ b/src/net/http/transport.go
@@ -1236,7 +1236,7 @@ func useProxy(addr string) bool {
addr = strings.ToLower(strings.TrimSpace(addr))
if hasPort(addr) {
- addr = addr[:strings.LastIndexByte(addr, ':')]
+ addr = addr[:strings.LastIndex(addr, ":")]
}
for _, p := range strings.Split(noProxy, ",") {
@@ -1245,7 +1245,7 @@ func useProxy(addr string) bool {
continue
}
if hasPort(p) {
- p = p[:strings.LastIndexByte(p, ':')]
+ p = p[:strings.LastIndex(p, ":")]
}
if addr == p {
return false
@@ -1317,7 +1317,7 @@ func (cm *connectMethod) addr() string {
func (cm *connectMethod) tlsHost() string {
h := cm.targetAddr
if hasPort(h) {
- h = h[:strings.LastIndexByte(h, ':')]
+ h = h[:strings.LastIndex(h, ":")]
}
return h
}