@@ -141,6 +141,9 @@ function InputStream(allocator::Ptr{aws_allocator}, body::RequestBodyTypes)
141141end
142142
143143function setinputstream! (msg:: Message , body)
144+ aws_http_message_set_body_stream (msg. ptr, C_NULL )
145+ msg. inputstream = nothing
146+ body === nothing && return
144147 input_stream = InputStream (msg. allocator, body)
145148 setfield! (msg, :inputstream , input_stream)
146149 if input_stream. ptr != C_NULL
158161mutable struct Request <: Message
159162 allocator:: Ptr{aws_allocator}
160163 ptr:: Ptr{aws_http_message}
161- inputstream:: InputStream # used for outgoing request body
164+ inputstream:: Union{Nothing, InputStream} # used for outgoing request body
162165 # only set in server-side request handlers
163166 body:: Union{Nothing, Vector{UInt8}}
164167 route:: Union{Nothing, String}
@@ -181,6 +184,7 @@ mutable struct Request <: Message
181184 end
182185 req = new (allocator, ptr)
183186 req. body = nothing
187+ req. inputstream = nothing
184188 req. route = nothing
185189 req. params = nothing
186190 req. cookies = nothing
@@ -291,7 +295,7 @@ RequestMetrics() = RequestMetrics(0, 0, 0, nothing)
291295mutable struct Response <: Message
292296 allocator:: Ptr{aws_allocator}
293297 ptr:: Ptr{aws_http_message}
294- inputstream:: InputStream
298+ inputstream:: Union{Nothing, InputStream}
295299 body:: Union{Nothing, Vector{UInt8}} # only set for client-side response body when no user-provided response_body
296300 metrics:: RequestMetrics
297301 request:: Request
@@ -311,6 +315,7 @@ mutable struct Response <: Message
311315 end
312316 resp = new (allocator, ptr)
313317 resp. body = nothing
318+ resp. inputstream = nothing
314319 body != = nothing && setinputstream! (resp, body)
315320 return finalizer (_ -> aws_http_message_release (ptr), resp)
316321 catch
@@ -324,6 +329,8 @@ Response(body=nothing) = Response(0, nothing, body)
324329Response (status:: Integer , body) = Response (status, nothing , Vector {UInt8} (string (body)))
325330Response (status:: Integer ) = Response (status, nothing , nothing )
326331
332+ bodylen (m:: Message ) = isdefined (m, :inputstream ) && m. inputstream != = nothing ? m. inputstream. bodylen : 0
333+
327334function Base. getproperty (x:: Response , s:: Symbol )
328335 if s == :status
329336 ref = Ref {Cint} ()
0 commit comments