(url string)
| 32 | } |
| 33 | |
| 34 | func NewTarget(url string) (*Target, error) { |
| 35 | |
| 36 | if url == "" { |
| 37 | return nil, fmt.Errorf("URL cannot be empty") |
| 38 | } |
| 39 | |
| 40 | if strings.ToLower(url[:4]) != "http" { |
| 41 | url = "https://" + url |
| 42 | } |
| 43 | u, err := neturl.Parse(url) |
| 44 | |
| 45 | if u.Scheme != "https" { |
| 46 | return nil, fmt.Errorf("H2C not implemented. If needed see the \"experimental-h2c\" branch") |
| 47 | } |
| 48 | |
| 49 | if u.Port() == "" { |
| 50 | u.Host = u.Host + ":443" |
| 51 | } |
| 52 | |
| 53 | if u.Path == "" { |
| 54 | u.Path = "/" |
| 55 | } |
| 56 | |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | return &Target{ |
| 61 | URL: *u, |
| 62 | }, nil |
| 63 | } |
| 64 | |
| 65 | func (t *Target) GetConnection() (*tls.Conn, error) { |
| 66 | var conn *tls.Conn |
no outgoing calls
no test coverage detected