Sha256: 07caae03a0a22435693301b569560b1dece532b4b4d80b3178ae7460563ce421

Contents?: true

Size: 579 Bytes

Versions: 58

Compression:

Stored size: 579 Bytes

Contents

#!/usr/bin/env ruby

require 'async'
require 'async/http/body/file'
require 'async/http/internet'

Async.run do
	internet = Async::HTTP::Internet.new
	
	headers = [
		['accept', 'text/plain'],
	]
	
	body = Async::HTTP::Body::File.open("data.txt")
	
	response = internet.post("https://www.codeotaku.com/journal/2018-10/async-http-client-for-ruby/echo", headers, body)
	
	# response.read -> string
	# response.each {|chunk| ...}
	# response.close (forcefully ignore data)
	# body = response.finish (read and buffer response)
	response.save("echo.txt")
	
ensure
	internet.close
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
async-http-0.48.2 examples/upload/upload.rb
async-http-0.48.1 examples/upload/upload.rb
async-http-0.48.0 examples/upload/upload.rb
async-http-0.47.0 examples/upload/upload.rb
async-http-0.46.5 examples/upload/upload.rb
async-http-0.46.4 examples/upload/upload.rb
async-http-0.46.3 examples/upload/upload.rb
async-http-0.46.2 examples/upload/upload.rb
async-http-0.46.1 examples/upload/upload.rb
async-http-0.46.0 examples/upload/upload.rb
async-http-0.45.9 examples/upload/upload.rb
async-http-0.45.8 examples/upload/upload.rb
async-http-0.45.7 examples/upload/upload.rb
async-http-0.45.6 examples/upload/upload.rb
async-http-0.45.4 examples/upload/upload.rb
async-http-0.45.3 examples/upload/upload.rb
async-http-0.45.2 examples/upload/upload.rb
async-http-0.45.1 examples/upload/upload.rb
async-http-0.45.0 examples/upload/upload.rb
async-http-0.44.0 examples/upload/upload.rb