(url string)
| 244 | } |
| 245 | |
| 246 | func 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 | |
| 275 | func getRequest(url string, header http.Header) (error, int, []byte) { |
| 276 |
no test coverage detected