suppose i have the following call to HTTP.jl
:
using HTTP
rsp = HTTP.request("GET", "https://www.google.com")
rsp
appears to contain the target HTML document, since a call to print
displays what look like the first few lines of a well-formed HTML payload:
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Date: Wed, 12 May 2021 05:24:04 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2021-05-12-05; expires=Fri, 11-Jun-2021 05:24:04 GMT; path=/; domain=.google.com; Secure
Set-Cookie: NID=215=rhS6AL0sDWhXxPPKRXMq4IUucLNO6fPZYKQgM_NIDYbhgJus66teBrucY9Wji3h3iXvymdE0_uD-oDcCl-fEEXnbmkHMg88cR1-XhQl5yHqtGXZN7_r4f07mUbTkva97KMXPsMxIoNNUAFS7ovNTVm9MWpkYOiRHW6ytlGHMt-k; expires=Thu, 11-Nov-2021 05:24:04 GMT; path=/; domain=.google.com; HttpOnly
Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Accept-Ranges: none
Vary: Accept-Encoding
Transfer-Encoding: chunked
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="GyBQgellYHlWflgrWWbR7Q==">(function(){window.google={kEI:'dGabYIfRE8GqtQaqyKyADA',kEXPI:'0,778759,523777,56872,955,5104,207,4804,926,1390,383,246,5,1354,4936,314,6385,1116131,1232,1196472,578,43,1,328941,51223,16115,19397,9287,17572,4859,1361,9291,3023,4744,12841,4020,978,13228,2054,1793,10622,1142,13385,4517,2778,919,2277,8,2796,1593,1279,2212,530,149,1103,842,515,1466,56,157,4101,3514,606,2023,1777,520,4269,328,1285,8788,3227,1989,856,7,12354,5096,7877,4928,108,1483,1371,553,908
⋮
13790-byte body
"""
i’d like to inspect the full text – but rsp.body
has type Vector{UInt8}
, and i’m sure how to convert that type into a human-readable string.
does Julia have a function analogous to str.encode
and str.decode
in Python? i.e. an idiom that would allow me to turn the binary-encoded payload from an HTTP call back into a readable string?
thanks in advance!