From 92ef51085a8fdb54f802517baf5eb92290f62771 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 14 Feb 2024 13:48:24 -0500 Subject: [PATCH] Implement bodysummary without private APIs --- src/Messages.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Messages.jl b/src/Messages.jl index 88ad2340..6adbd340 100644 --- a/src/Messages.jl +++ b/src/Messages.jl @@ -583,8 +583,17 @@ The first chunk of the Message Body (for display purposes). bodysummary(body) = isbytes(body) ? view(bytes(body), 1:min(nbytes(body), BODY_SHOW_MAX[])) : "[Message Body was streamed]" bodysummary(body::Union{AbstractDict, NamedTuple}) = URIs.escapeuri(body) function bodysummary(body::Form) - if length(body.data) == 1 && isa(body.data[1], IOBuffer) - return body.data[1].data[1:body.data[1].ptr-1] + if length(body.data) == 1 + data = body.data[1] + if data isa Base.GenericIOBuffer && data.seekable + oldmark = data.mark + m = mark(data) + seekstart(data) + content = read(data, m) + reset(data) + data.mark = oldmark + return content + end end return "[Message Body was streamed]" end