MCPcopy
hub / github.com/syncthing/syncthing / Post

Method Post

lib/rc/rc.go:193–215  ·  view source on GitHub ↗

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

(path string, data io.Reader)

Source from the content-addressed store, hash-verified

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.
193func (p *Process) Post(path string, data io.Reader) ([]byte, error) {
194 client := &http.Client{
195 Timeout: 600 * time.Second,
196 Transport: &http.Transport{
197 DisableKeepAlives: true,
198 },
199 }
200 url := fmt.Sprintf("http://%s%s", p.addr, path)
201 req, err := http.NewRequest(http.MethodPost, url, data)
202 if err != nil {
203 return nil, err
204 }
205
206 req.Header.Add("X-Api-Key", APIKey)
207 req.Header.Add("Content-Type", "application/json")
208
209 resp, err := client.Do(req)
210 if err != nil {
211 return nil, err
212 }
213
214 return p.readResponse(resp)
215}
216
217type Event struct {
218 ID int

Callers 9

StopMethod · 0.95
RescanMethod · 0.95
RescanDelayMethod · 0.95
RescanSubsMethod · 0.95
PostConfigMethod · 0.95
PauseDeviceMethod · 0.95
ResumeDeviceMethod · 0.95
PauseAllMethod · 0.95
ResumeAllMethod · 0.95

Calls 3

readResponseMethod · 0.95
DoMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected