@@ -42,6 +42,7 @@ function write_callback(
4242 GRPC_INTERNAL,
4343 " Recieved $(n) bytes from curl but only handled $(handled_n_bytes_total) " ,
4444 )
45+ # If we are response streaming unblock the task waiting on response_c
4546 ! isnothing (req. response_c) && close (req. response_c)
4647 return typemax (Csize_t)
4748 end
@@ -129,7 +130,25 @@ function header_callback(
129130 end
130131end
131132
132-
133+ function grpc_timeout_header_val (timeout:: Real )
134+ if round (Int, timeout) == timeout
135+ timeout_secs = round (Int64, timeout)
136+ return " $(timeout_secs) S"
137+ end
138+ timeout *= 1000
139+ if round (Int, timeout) == timeout
140+ timeout_millisecs = round (Int64, timeout)
141+ return " $(timeout_millisecs) m"
142+ end
143+ timeout *= 1000
144+ if round (Int, timeout) == timeout
145+ timeout_microsecs = round (Int64, timeout)
146+ return " $(timeout_microsecs) u"
147+ end
148+ timeout *= 1000
149+ timeout_nanosecs = round (Int64, timeout)
150+ return " $(timeout_nanosecs) n"
151+ end
133152
134153mutable struct gRPCRequest
135154 # CURL multi lock for exclusive access to the easy handle after its added to the multi
@@ -221,26 +240,6 @@ mutable struct gRPCRequest
221240 curl_easy_setopt (easy_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS)
222241 end
223242
224- function grpc_timeout_header_val (timeout:: Real )
225- if round (Int, timeout) == timeout
226- timeout_secs = round (Int64, timeout)
227- return " $(timeout_secs) S"
228- end
229- timeout *= 1000
230- if round (Int, timeout) == timeout
231- timeout_millisecs = round (Int64, timeout)
232- return " $(timeout_millisecs) m"
233- end
234- timeout *= 1000
235- if round (Int, timeout) == timeout
236- timeout_microsecs = round (Int64, timeout)
237- return " $(timeout_microsecs) u"
238- end
239- timeout *= 1000
240- timeout_nanosecs = round (Int64, timeout)
241- return " $(timeout_nanosecs) n"
242- end
243-
244243 headers = C_NULL
245244 headers = curl_slist_append (headers, " User-Agent: $(USER_AGENT) " )
246245 headers = curl_slist_append (headers, " Content-Type: application/grpc+proto" )
@@ -352,6 +351,7 @@ function handle_write(req::gRPCRequest, buf::Vector{UInt8})::Tuple{Int64, Union{
352351 GRPC_UNIMPLEMENTED,
353352 " Response was compressed but compression is not currently supported." ,
354353 )
354+ # If we are response streaming unblock the task waiting on response_c
355355 ! isnothing (req. response_c) && close (req. response_c)
356356 notify (req. ready)
357357 return n, nothing
@@ -360,6 +360,7 @@ function handle_write(req::gRPCRequest, buf::Vector{UInt8})::Tuple{Int64, Union{
360360 GRPC_RESOURCE_EXHAUSTED,
361361 " length-prefix longer than max_recieve_message_length: $(req. response_length) > $(req. max_recieve_message_length) " ,
362362 )
363+ # If we are response streaming unblock the task waiting on response_c
363364 ! isnothing (req. response_c) && close (req. response_c)
364365 notify (req. ready)
365366 return n, nothing
0 commit comments