MCPcopy
hub / github.com/syncthing/syncthing / Get

Method Get

lib/rc/rc.go:165–189  ·  view source on GitHub ↗

Get performs an HTTP GET and returns the bytes and/or an error. Any non-200 return code is returned as an error.

(path string)

Source from the content-addressed store, hash-verified

163// Get performs an HTTP GET and returns the bytes and/or an error. Any non-200
164// return code is returned as an error.
165func (p *Process) Get(path string) ([]byte, error) {
166 client := &http.Client{
167 Timeout: 30 * time.Second,
168 Transport: &http.Transport{
169 DialContext: dialer.DialContext,
170 Proxy: http.ProxyFromEnvironment,
171 DisableKeepAlives: true,
172 },
173 }
174
175 url := fmt.Sprintf("http://%s%s", p.addr, path)
176 req, err := http.NewRequest(http.MethodGet, url, nil)
177 if err != nil {
178 return nil, err
179 }
180
181 req.Header.Add("X-Api-Key", APIKey)
182
183 resp, err := client.Do(req)
184 if err != nil {
185 return nil, err
186 }
187
188 return p.readResponse(resp)
189}
190
191// Post performs an HTTP POST and returns the bytes and/or an error. Any
192// non-200 return code is returned as an error.

Callers 8

EventsMethod · 0.95
ConfigInSyncMethod · 0.95
GetConfigMethod · 0.95
ModelMethod · 0.95
ConnectionsMethod · 0.95
SystemStatusMethod · 0.95
SystemVersionMethod · 0.95
RemoteInSyncMethod · 0.95

Calls 3

readResponseMethod · 0.95
DoMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected