mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-15 00:00:39 -04:00
small cleanup in type definitions and webmock testing
This commit is contained in:
parent
354bba3179
commit
79756e4ac4
@ -26,6 +26,7 @@ class WebmockTest < Minitest::Test
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
WebMock.reset!
|
||||
WebMock.allow_net_connect!
|
||||
WebMock.disable!
|
||||
@ -233,10 +234,11 @@ class WebmockTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_webmock_with_stream_plugin_each
|
||||
session = HTTPX.plugin(:stream)
|
||||
request = stub_request(:get, MOCK_URL_HTTP).to_return(body: "body")
|
||||
|
||||
body = "".b
|
||||
response = HTTPX.plugin(:stream).get(MOCK_URL_HTTP, stream: true)
|
||||
response = session.get(MOCK_URL_HTTP, stream: true)
|
||||
response.each do |chunk|
|
||||
next if (300..399).cover?(response.status)
|
||||
|
||||
|
@ -1,26 +1,4 @@
|
||||
module HTTPX
|
||||
class StreamResponse
|
||||
include _ToS
|
||||
|
||||
@request: Request & RequestMethods
|
||||
@session: sessionStream
|
||||
@on_chunk: ^(String) -> void | nil
|
||||
|
||||
def each: () { (String) -> void } -> void
|
||||
| () -> Enumerable[String]
|
||||
|
||||
def each_line: () { (String) -> void } -> void
|
||||
| () -> Enumerable[String]
|
||||
|
||||
def on_chunk: (string) -> void
|
||||
|
||||
def initialize: (Request, Session) -> void
|
||||
|
||||
private
|
||||
|
||||
def response: () -> response
|
||||
end
|
||||
|
||||
module Plugins
|
||||
module Stream
|
||||
module InstanceMethods
|
||||
@ -42,4 +20,28 @@ module HTTPX
|
||||
|
||||
type sessionStream = Session & Stream::InstanceMethods
|
||||
end
|
||||
|
||||
class StreamResponse
|
||||
include _ToS
|
||||
|
||||
type streamRequest = Request & Plugins::Stream::RequestMethods
|
||||
|
||||
@request: streamRequest
|
||||
@session: Plugins::sessionStream
|
||||
@on_chunk: ^(String) -> void | nil
|
||||
|
||||
def each: () { (String) -> void } -> void
|
||||
| () -> Enumerable[String]
|
||||
|
||||
def each_line: () { (String) -> void } -> void
|
||||
| () -> Enumerable[String]
|
||||
|
||||
def on_chunk: (string) -> void
|
||||
|
||||
def initialize: (streamRequest, Plugins::sessionStream) -> void
|
||||
|
||||
private
|
||||
|
||||
def response: () -> response
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user