Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: common/lhttp/utils.go

Issue 2227113002: Update bulidbucket client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/cmd/buildbucket/put.go ('k') | dm/appengine/distributor/jobsim/run.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package lhttp 5 package lhttp
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "net"
9 "net/url" 10 "net/url"
10 "strings" 11 "strings"
11 ) 12 )
12 13
13 func hostRequiresSSL(host string) bool { 14 func hostRequiresSSL(host string) bool {
14 host = strings.ToLower(host) 15 host = strings.ToLower(host)
15 return strings.HasSuffix(host, ".appspot.com") 16 return strings.HasSuffix(host, ".appspot.com")
16 } 17 }
17 18
18 // CheckURL ensures that the URL has a valid scheme, and that, if it is an 19 // CheckURL ensures that the URL has a valid scheme, and that, if it is an
(...skipping 13 matching lines...) Expand all
32 return "", errors.New("Only http:// or https:// scheme is accept ed.") 33 return "", errors.New("Only http:// or https:// scheme is accept ed.")
33 } 34 }
34 if u.Scheme != "https" && hostRequiresSSL(u.Host) { 35 if u.Scheme != "https" && hostRequiresSSL(u.Host) {
35 return "", errors.New("only https:// scheme is accepted for apps pot hosts, it can be omitted") 36 return "", errors.New("only https:// scheme is accepted for apps pot hosts, it can be omitted")
36 } 37 }
37 if _, err = url.Parse(s); err != nil { 38 if _, err = url.Parse(s); err != nil {
38 return "", err 39 return "", err
39 } 40 }
40 return s, nil 41 return s, nil
41 } 42 }
43
44 // IsLocalHost returns true if hostport is local.
45 func IsLocalHost(hostport string) bool {
46 host, _, err := net.SplitHostPort(hostport)
47 if err != nil {
48 return false
49 }
50 switch {
51 case host == "localhost", host == "":
52 case net.ParseIP(host).IsLoopback():
53
54 default:
55 return false
56 }
57 return true
58 }
OLDNEW
« no previous file with comments | « client/cmd/buildbucket/put.go ('k') | dm/appengine/distributor/jobsim/run.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698