[swift6][alamofire] Report -1, not 500, when there is no HTTP response
Fixes #25187.
response?.statusCode ?? 500becomes?? -1in all five alamofire failure paths, matching the urlsession library's-1for transport errors. When there is a response, its real status code is reported as before.- A failed file download reports the response's status code (or
-1) and Alamofire's underlying error, instead of400+DownloadException.responseFailed.
Behaviour change: callers that check for 500 to detect any failure will no longer see network failures there. They should check for -1, or inspect the underlying AFError/URLError, which is unchanged.
Verified downstream with an offline URLProtocol stub: an Alamofire request without a response now reports -1 with AFError wrapping URLError.notConnectedToInternet. The alamofireLibrary sample builds.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
Commit all changed files../mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/swift6*.yaml || exit - @mention the technical committee: @jgavris @ehyche @Edubits @jaz-ah @4brunu @dydus0x14
Summary by cubic
Reports -1 instead of 500 when an Alamofire failure has no HTTP response, matching how the urlsession library reports transport errors like offline, timeout, and cancellation. A failed file download now reports the response's status code (or -1) with the underlying Alamofire error instead of 400 with DownloadException.responseFailed.
Callers that check for 500 to detect any failure will no longer see network failures there; they should check for -1 or inspect the underlying AFError/URLError, which is unchanged.