Currently, the order of execution when processing an HTTP response is:
- Log the body, if configured.
- Check the response code and fail if it isn't in the expected range.
- Write the response to a file.
The result of this is that consoleLogResponseBody and outputFile aren't equivalent: the former happens regardless of response status but the latter only happens if the status is in the expected range.
This is the code in question:
This ticket proposes changing this so that the response content is always written to a file, if configured, regardless of the response status.
My use case is uploading a large amount of data to Elasticsearch. The response is correspondingly large so I don't want to log it to the console, plus it's JSON so I'd prefer to write it to a file for easier querying in any case. So I set outputFile and archive that file, but if my request fails the file isn't written and I can't diagnose the issue. Instead I'm going to have to change my plugin call to allow any HTTP status and then write the response body to a file before manually checking the status.