[Ruby] add file download tests (#17362)

* add new ruby echo api clients

* add tests for ruby faraday file download

* add file download test to ruby Typhoeus

* add ruby workflow, add tests for ruby httpx

* update

* fix
This commit is contained in:
William Cheng
2023-12-09 22:05:27 +08:00
committed by GitHub
parent dd36fa09f8
commit 10da7a3c5a
156 changed files with 17233 additions and 315 deletions

View File

@@ -187,14 +187,16 @@ module DynamicServers
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
# run the request to ensure the tempfile is created successfully before returning it
request.run
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
else
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
end
tempfile