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
Replace FIFOBuffer implementation with BufferStream/IOBuffer wrapper.
Add mark/reset support to Form <: IO
Dont call eof() in body(::IO, ...) if content length is known (eof() can block)
Work around JuliaLang/julia#24465
Use non-blocking readavailable() to read serverlog in test/server.jl
Hack test/fifobuffer.jl to work with BufferStream/IOBuffer implementation.
The BufferStream API does not expose the size of the buffer, so tests
that passed a fixed size to FIFOBuffer(n) have been tweaked to pass with
BufferStream's automatic buffer size managment behaviour.
Add note re @test_broken and https://github.com/kennethreitz/httpbin/issues/340#issuecomment-330176449
A `FIFOBuffer` is a first-in, first-out, in-memory, async-friendly IO buffer type.
13
-
14
-
`FIFOBuffer([max])`: creates a "open" `FIFOBuffer` with a maximum size of `max`; this means that bytes can be written
15
-
up until `max` number of bytes have been written (with none being read). At this point, the `FIFOBuffer` is full
16
-
and will return 0 for all subsequent writes. If no `max` (`FIFOBuffer()`) argument is given, then a default size of `typemax(Int32)^2` is used;
17
-
this essentially allows all writes every time. Note that providing a string or byte vector argument mirrors the behavior of `Base.IOBuffer`
18
-
in that the `max` size of the `FIFOBuffer` is the length of the string/byte vector; it is also not writeable.
19
-
20
-
Reading is supported via `readavailable(f)` and `read(f, nb)`, which returns all or `nb` bytes, respectively, starting at the earliest bytes written.
21
-
All read functions will return an empty byte vector, even if the buffer has been closed. Checking `eof` will correctly reflect when the buffer has
22
-
been closed and no more bytes will be available for reading.
23
-
24
-
You may call `String(f::FIFOBuffer)` to view the current contents in the buffer without consuming them.
25
-
26
-
A `FIFOBuffer` is built to be used asynchronously to allow buffered reading and writing. In particular, a `FIFOBuffer`
27
-
detects if it is being read from/written to the main task, or asynchronously, and will behave slightly differently depending on which.
28
-
29
-
Specifically, when reading from a `FIFOBuffer`, if accessed from the main task, it will not block if there are no bytes available to read, instead returning an empty `UInt8[]`.
30
-
If being read from asynchronously, however, reading will block until additional bytes have been written. An example of this in action is:
31
-
32
-
```julia
33
-
f = HTTP.FIFOBuffer(5) # create a FIFOBuffer that will hold at most 5 bytes, currently empty
34
-
f2 = HTTP.FIFOBuffer(5) # a 2nd buffer that we'll write to asynchronously
35
-
36
-
# start an asynchronous writing task with the 2nd buffer
0 commit comments