@@ -141,6 +141,9 @@ function InputStream(allocator::Ptr{aws_allocator}, body::RequestBodyTypes)
141
141
end
142
142
143
143
function setinputstream! (msg:: Message , body)
144
+ aws_http_message_set_body_stream (msg. ptr, C_NULL )
145
+ msg. inputstream = nothing
146
+ body === nothing && return
144
147
input_stream = InputStream (msg. allocator, body)
145
148
setfield! (msg, :inputstream , input_stream)
146
149
if input_stream. ptr != C_NULL
158
161
mutable struct Request <: Message
159
162
allocator:: Ptr{aws_allocator}
160
163
ptr:: Ptr{aws_http_message}
161
- inputstream:: InputStream # used for outgoing request body
164
+ inputstream:: Union{Nothing, InputStream} # used for outgoing request body
162
165
# only set in server-side request handlers
163
166
body:: Union{Nothing, Vector{UInt8}}
164
167
route:: Union{Nothing, String}
@@ -181,6 +184,7 @@ mutable struct Request <: Message
181
184
end
182
185
req = new (allocator, ptr)
183
186
req. body = nothing
187
+ req. inputstream = nothing
184
188
req. route = nothing
185
189
req. params = nothing
186
190
req. cookies = nothing
@@ -291,7 +295,7 @@ RequestMetrics() = RequestMetrics(0, 0, 0, nothing)
291
295
mutable struct Response <: Message
292
296
allocator:: Ptr{aws_allocator}
293
297
ptr:: Ptr{aws_http_message}
294
- inputstream:: InputStream
298
+ inputstream:: Union{Nothing, InputStream}
295
299
body:: Union{Nothing, Vector{UInt8}} # only set for client-side response body when no user-provided response_body
296
300
metrics:: RequestMetrics
297
301
request:: Request
@@ -311,6 +315,7 @@ mutable struct Response <: Message
311
315
end
312
316
resp = new (allocator, ptr)
313
317
resp. body = nothing
318
+ resp. inputstream = nothing
314
319
body != = nothing && setinputstream! (resp, body)
315
320
return finalizer (_ -> aws_http_message_release (ptr), resp)
316
321
catch
@@ -324,6 +329,8 @@ Response(body=nothing) = Response(0, nothing, body)
324
329
Response (status:: Integer , body) = Response (status, nothing , Vector {UInt8} (string (body)))
325
330
Response (status:: Integer ) = Response (status, nothing , nothing )
326
331
332
+ bodylen (m:: Message ) = isdefined (m, :inputstream ) && m. inputstream != = nothing ? m. inputstream. bodylen : 0
333
+
327
334
function Base. getproperty (x:: Response , s:: Symbol )
328
335
if s == :status
329
336
ref = Ref {Cint} ()
0 commit comments