You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update readbytes! to avoid using internal API of IOBuffer less (#1148)
* Update readbytes! to avoid using internal API of IOBuffer less
Note that this claims to be supported for all GenericIOBuffer, but Base only defines this function on a normal IOBuffer for which `pointer(data)` is contiguous space
* Update Streams.jl
* Update Streams.jl
* Update Streams.jl
* fix some tests relying on implementation details
requested_buffer_capacity = (buf.append ? buf.size : (buf.ptr -1)) + n
284
-
requested_buffer_capacity >length(buf.data) &&throw(ArgumentError("Unable to grow response stream IOBuffer $(length(buf.data)) large enough for response body size: $requested_buffer_capacity"))
285
-
end
286
-
287
282
function Base.readbytes!(http::Stream, buf::Base.GenericIOBuffer, n=bytesavailable(http))
288
-
Base.ensureroom(buf, n)
289
-
# check if there's enough room in buf to write n bytes
290
-
bufcheck(buf, n)
291
-
data = buf.data
292
-
GC.@preserve data unsafe_read(http, pointer(data, (buf.append ? buf.size +1: buf.ptr)), n)
283
+
p, nbmax = Base.alloc_request(buf, UInt(n))
284
+
nbmax < n &&throw(ArgumentError("Unable to grow response stream IOBuffer $nbmax large enough for response body size: $n"))
285
+
GC.@preserve buf unsafe_read(http, p, UInt(n))
286
+
#TODO: use `Base.notify_filled(buf, Int(n))` here, but only once it is identical to this:
293
287
if buf.append
294
-
buf.size +=n
288
+
buf.size +=Int(n)
295
289
else
296
-
buf.ptr +=n
290
+
buf.ptr +=Int(n)
297
291
buf.size =max(buf.size, buf.ptr -1)
298
292
end
299
293
return n
@@ -327,6 +321,7 @@ function IOExtras.readuntil(http::Stream, f::Function)
327
321
update_ntoread(http, length(bytes))
328
322
return bytes
329
323
catch ex
324
+
ex isa EOFError ||rethrow()
330
325
# if we error, it means we didn't find what we were looking for
0 commit comments