equal
deleted
inserted
replaced
113 func (l *Loader) LoadURL(url string) (*Properties, error) { |
113 func (l *Loader) LoadURL(url string) (*Properties, error) { |
114 resp, err := http.Get(url) |
114 resp, err := http.Get(url) |
115 if err != nil { |
115 if err != nil { |
116 return nil, fmt.Errorf("properties: error fetching %q. %s", url, err) |
116 return nil, fmt.Errorf("properties: error fetching %q. %s", url, err) |
117 } |
117 } |
|
118 defer resp.Body.Close() |
118 |
119 |
119 if resp.StatusCode == 404 && l.IgnoreMissing { |
120 if resp.StatusCode == 404 && l.IgnoreMissing { |
120 LogPrintf("properties: %s returned %d. skipping", url, resp.StatusCode) |
121 LogPrintf("properties: %s returned %d. skipping", url, resp.StatusCode) |
121 return NewProperties(), nil |
122 return NewProperties(), nil |
122 } |
123 } |
127 |
128 |
128 body, err := ioutil.ReadAll(resp.Body) |
129 body, err := ioutil.ReadAll(resp.Body) |
129 if err != nil { |
130 if err != nil { |
130 return nil, fmt.Errorf("properties: %s error reading response. %s", url, err) |
131 return nil, fmt.Errorf("properties: %s error reading response. %s", url, err) |
131 } |
132 } |
132 defer resp.Body.Close() |
|
133 |
133 |
134 ct := resp.Header.Get("Content-Type") |
134 ct := resp.Header.Get("Content-Type") |
135 var enc Encoding |
135 var enc Encoding |
136 switch strings.ToLower(ct) { |
136 switch strings.ToLower(ct) { |
137 case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1": |
137 case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1": |