fail.md (1082B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Long: fail 5 Short: f 6 Protocols: HTTP 7 Help: Fail fast with no output on HTTP errors 8 Category: important http 9 Mutexed: fail-with-body 10 Added: 4.0 11 Multi: boolean 12 See-also: 13 - fail-with-body 14 - fail-early 15 Example: 16 - --fail $URL 17 --- 18 19 # `--fail` 20 21 Fail with error code 22 and with no response body output at all for HTTP 22 transfers returning HTTP response codes at 400 or greater. 23 24 In normal cases when an HTTP server fails to deliver a document, it returns a 25 body of text stating so (which often also describes why and more) and a 4xx 26 HTTP response code. This command line option prevents curl from outputting 27 that data and instead returns error 22 early. By default, curl does not 28 consider HTTP response codes to indicate failure. 29 30 To get both the error code and also save the content, use --fail-with-body 31 instead. 32 33 This method is not fail-safe and there are occasions where non-successful 34 response codes slip through, especially when authentication is involved 35 (response codes 401 and 407).