korio question: Reading file content from a URL. P...
# korge
d
korio question: Reading file content from a URL. Potentially nice and easy, there is a UrlVfs. But what to do if the URL requires credentials ?
d
Since
UrlVfs
accepts a
HttpClient
, you can create a custom
HttpClient
(by implementing the
requestInternal
method that redirects it to a other HttpClient (one created with
createHttpClient()
modifying its headers), that would actually act as an interceptor)
d
thx
however, must be a bug either in HttpClient...or my use of it.
Copy code
val resp = client.request(Http.Method.GET,uriStr)
val cnt = resp.content
val sb = StringBuilder()
resp.responseCharset.decode(sb, cnt.readAll())
val t0=sb.toString()
I have tried various other options...but nothing gives me the correct content. Using java libs direct works fine.
OK, I think the issue is that the response is gzipped,
Copy code
response.headers["Content-Encoding"] == "gzip"
so, issue is how to unzip it, any pointers to something in korio that will help?, I see a ZipBuilder
hmm...or maybe its Base64 encoded
or both ?
d
it should probably check the content-encoding and ungzip it when required
d
I would have expected that...doesn't seem to do so. I'm trying to get a raw file from a gitlab repo. a Pure java version works, so I know the link and access is correct. any hints on where to look for the issue?