MCPcopy
hub / github.com/mudler/LocalAI / postInvalidRequest

Function postInvalidRequest

core/http/app_test.go:246–273  ·  view source on GitHub ↗
(url string)

Source from the content-addressed store, hash-verified

244}
245
246func postInvalidRequest(url string) (error, int) {
247
248 req, err := http.NewRequest("POST", url, bytes.NewBufferString("invalid request"))
249 if err != nil {
250 return err, -1
251 }
252
253 req.Header.Set("Content-Type", "application/json")
254
255 client := &http.Client{}
256 resp, err := client.Do(req)
257 if err != nil {
258 return err, -1
259 }
260
261 defer resp.Body.Close()
262
263 body, err := io.ReadAll(resp.Body)
264 if err != nil {
265 return err, -1
266 }
267
268 if resp.StatusCode < 200 || resp.StatusCode >= 400 {
269 return fmt.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, string(body)), resp.StatusCode
270 }
271
272 return nil, resp.StatusCode
273}
274
275func getRequest(url string, header http.Header) (error, int, []byte) {
276

Callers 1

app_test.goFile · 0.85

Calls 2

SetMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected