https://kotlinlang.org logo
Title
d

Dave

04/26/2021, 10:41 AM
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

Deactivated User

04/26/2021, 10:51 AM
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

Dave

04/26/2021, 3:08 PM
thx
however, must be a bug either in HttpClient...or my use of it.
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,
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

Deactivated User

04/28/2021, 6:43 PM
it should probably check the content-encoding and ungzip it when required
d

Dave

04/29/2021, 8:56 AM
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?