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

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

Issue 1159563002: Move retry and lhttp packages from client/internal to common/. (Closed) Base URL: git@github.com:luci/luci-go@master
Patch Set: move-retry-http Created 5 years, 7 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 | « common/lhttp/doc.go ('k') | common/lhttp/utils_test.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 Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // 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/url" 9 "net/url"
10 "strings" 10 "strings"
11 ) 11 )
12 12
13 // URLToHTTPS ensures the url is https://. 13 // URLToHTTPS ensures the url is https://.
14 func URLToHTTPS(s string) (string, error) { 14 func URLToHTTPS(s string) (string, error) {
15 u, err := url.Parse(s) 15 u, err := url.Parse(s)
16 if err != nil { 16 if err != nil {
17 return "", err 17 return "", err
18 } 18 }
19 if u.Scheme != "" && u.Scheme != "https" { 19 if u.Scheme != "" && u.Scheme != "https" {
20 return "", errors.New("Only https:// scheme is accepted. It can be omitted.") 20 return "", errors.New("Only https:// scheme is accepted. It can be omitted.")
21 } 21 }
22 if !strings.HasPrefix(s, "https://") { 22 if !strings.HasPrefix(s, "https://") {
23 s = "https://" + s 23 s = "https://" + s
24 } 24 }
25 if _, err = url.Parse(s); err != nil { 25 if _, err = url.Parse(s); err != nil {
26 return "", err 26 return "", err
27 } 27 }
28 return s, nil 28 return s, nil
29 } 29 }
OLDNEW
« no previous file with comments | « common/lhttp/doc.go ('k') | common/lhttp/utils_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698