Skip to content

Commit

Permalink
Try another fix for gc root 1.11 response_headers callback issue
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Sep 23, 2024
1 parent 1cbf863 commit ea162b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/HTTP2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ mutable struct RequestContext
request_body::Any
body_byte_cursor::aws_byte_cursor
response::Response
response_headers::Headers
temp_response_body::Any
gzip_decompressing::Bool
error_response_body::Union{Nothing, Vector{UInt8}}
Expand All @@ -259,7 +260,7 @@ mutable struct RequestContext
end

function RequestContext(client, request, response, args...)
return RequestContext(client, C_NULL, false, Threads.Event(), nothing, request, nothing, aws_byte_cursor(0, C_NULL), response, nothing, false, nothing, Ref{aws_http_make_request_options}(), C_NULL, C_NULL, args...)
return RequestContext(client, C_NULL, false, Threads.Event(), nothing, request, nothing, aws_byte_cursor(0, C_NULL), response, Headers(), nothing, false, nothing, Ref{aws_http_make_request_options}(), C_NULL, C_NULL, args...)
end

struct StatusError <: Exception
Expand Down
3 changes: 2 additions & 1 deletion src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const on_response_headers = Ref{Ptr{Cvoid}}(C_NULL)

function c_on_response_headers(stream, header_block, header_array::Ptr{aws_http_header}, num_headers, ctx_ptr)
ctx = unsafe_pointer_to_objref(ctx_ptr)
headers = ctx.response.headers
headers = ctx.response_headers
oldlen = length(headers)
resize!(headers, oldlen + num_headers)
for i = 1:num_headers
Expand All @@ -211,6 +211,7 @@ const on_response_header_block_done = Ref{Ptr{Cvoid}}(C_NULL)
function c_on_response_header_block_done(stream, header_block, ctx_ptr)
ctx = unsafe_pointer_to_objref(ctx_ptr)
ref = Ref{Cint}()
ctx.response.headers = ctx.response_headers
aws_http_stream_get_incoming_response_status(stream, ref)
ctx.response.status = ref[]
if ctx.status_exception && ctx.response.status >= 299
Expand Down

0 comments on commit ea162b1

Please sign in to comment.