Skip to content

Commit

Permalink
Implement bodysummary without private APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Feb 14, 2024
1 parent 8f9eb57 commit 0bb15a9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0bb15a9

Please sign in to comment.