mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
fixing issues around typing
This commit is contained in:
parent
c70209db4b
commit
535a30db25
@ -12,14 +12,22 @@ module HTTPX::Transcoder
|
||||
|
||||
MIME_TYPES = %r{\b(application|text)/(.+\+)?xml\b}.freeze
|
||||
|
||||
class Encoder < SimpleDelegator
|
||||
class Encoder
|
||||
def initialize(xml)
|
||||
@raw = xml
|
||||
end
|
||||
|
||||
def content_type
|
||||
charset = respond_to?(:encoding) ? encoding.to_s.downcase : "utf-8"
|
||||
charset = @raw.respond_to?(:encoding) ? @raw.encoding.to_s.downcase : "utf-8"
|
||||
"application/xml; charset=#{charset}"
|
||||
end
|
||||
|
||||
def bytesize
|
||||
to_s.bytesize
|
||||
@raw.to_s.bytesize
|
||||
end
|
||||
|
||||
def to_s
|
||||
@raw.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -20,7 +20,7 @@ module HTTPX::Transcoder
|
||||
|
||||
private
|
||||
|
||||
def initialize: (_ToJson json) -> untyped
|
||||
def initialize: (_ToJson json) -> void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
21
sig/transcoder/xml.rbs
Normal file
21
sig/transcoder/xml.rbs
Normal file
@ -0,0 +1,21 @@
|
||||
module HTTPX::Transcoder
|
||||
module XML
|
||||
|
||||
def self?.encode: (untyped xml) -> Encoder
|
||||
def self?.decode: (HTTPX::Response response) -> _Decoder
|
||||
|
||||
class Encoder
|
||||
@raw: untyped # can be nokogiri object
|
||||
|
||||
def content_type: () -> String
|
||||
|
||||
def bytesize: () -> (Integer | Float)
|
||||
|
||||
def to_s: () -> String
|
||||
|
||||
private
|
||||
|
||||
def initialize: (String xml) -> void
|
||||
end
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@ RUBY_ENGINE=`ruby -e 'puts RUBY_ENGINE'`
|
||||
IPTABLES=iptables-translate
|
||||
|
||||
if [[ "$RUBY_ENGINE" = "truffleruby" ]]; then
|
||||
dnf install -y iptables iproute which file idn2 git
|
||||
dnf install -y iptables iproute which file idn2 git xz
|
||||
elif [[ "$RUBY_PLATFORM" = "java" ]]; then
|
||||
apt-get update && apt-get install -y build-essential iptables iproute2 file idn2 git
|
||||
elif [[ ${RUBY_VERSION:0:3} = "2.1" ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user