mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-16 00:01:48 -04:00
body tests: testing the diverse supported input types (can't test chunked bodies, as nghttp is not helping)
This commit is contained in:
parent
bf6652526e
commit
12c0ff29af
@ -39,6 +39,41 @@ module Requests
|
||||
verify_uploaded(body, "data", "data")
|
||||
end
|
||||
|
||||
define_method :"test_#{meth}_body_ary_params" do
|
||||
uri = build_uri("/#{meth}")
|
||||
response = HTTPX.send(meth, uri, body: %w[d a t a])
|
||||
verify_status(response.status, 200)
|
||||
body = json_body(response)
|
||||
verify_header(body["headers"], "Content-Type", "application/octet-stream")
|
||||
verify_uploaded(body, "data", "data")
|
||||
end
|
||||
|
||||
# TODO: nghttp not receiving chunked requests, investigate
|
||||
# define_method :"test_#{meth}_body_enum_params" do
|
||||
# uri = build_uri("/#{meth}")
|
||||
# body = Enumerator.new do |y|
|
||||
# y << "d"
|
||||
# y << "a"
|
||||
# y << "t"
|
||||
# y << "a"
|
||||
# end
|
||||
# response = HTTPX.send(meth, uri, body: body)
|
||||
# verify_status(response.status, 200)
|
||||
# body = json_body(response)
|
||||
# verify_header(body["headers"], "Content-Type", "application/octet-stream")
|
||||
# verify_uploaded(body, "data", "data")
|
||||
# end
|
||||
|
||||
define_method :"test_#{meth}_body_io_params" do
|
||||
uri = build_uri("/#{meth}")
|
||||
body = StringIO.new("data")
|
||||
response = HTTPX.send(meth, uri, body: body)
|
||||
verify_status(response.status, 200)
|
||||
body = json_body(response)
|
||||
verify_header(body["headers"], "Content-Type", "application/octet-stream")
|
||||
verify_uploaded(body, "data", "data")
|
||||
end
|
||||
|
||||
define_method :"test_#{meth}_form_file_params" do
|
||||
uri = build_uri("/#{meth}")
|
||||
response = HTTPX.send(meth, uri, form: {image: HTTP::FormData::File.new(fixture_file_path)})
|
||||
|
Loading…
x
Reference in New Issue
Block a user